我在基于消息传递的 iPhone 应用程序中工作。在我的一个 UIViewController 中,我正在显示 UITextView 键盘并从 web 服务中收到一些警报消息。
当我在 UIAlertView 中显示警报消息时,通过单击 UIAlertView 中的确定按钮来关闭 UITextview 键盘。我试图将 becomeFirstResponder 放在 UIAlertView 委托中,但仍然键盘关闭。供你参考,
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
[messageTextView becomeFirstResponder]; // Here again I am giving becomeFirstResponder to my UITextView
int alertMessageArrayCount = [alertMessageArray count];
if (messageAlertView)
{
if (messageAlertCount < alertMessageArrayCount) // These codes to show my all messages in UIAlertView one by one..
{
messageAlertCount = messageAlertCount + 1;
arrayObjectValue = arrayObjectValue + 1;
NSString *alertMessage = [alertMessageArray objectAtIndex:arrayObjectValue];
messageAlertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:alertMessage delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[messageAlertView show];
[messageAlertView release];
}
}
}
有人可以帮忙解决这个问题吗?
编辑 :
messageTextView = [[UITextView alloc] initWithFrame:CGRectMake(35, 5, 210, 30)];
messageTextView.delegate = self;
messageTextView.backgroundColor = [UIColor clearColor];
messageTextView.clipsToBounds = NO;
messageTextView.font = [UIFont fontWithName:@"Helvetica" size:14];
[self.view addSubView:messageTextView];