在我的添加联系人页面中,正在验证我的电子邮件文本字段、电话号码字段等。并在单击所有其他文本字段时检查有效电子邮件。因此,当我单击电话号码字段时,它将检查电子邮件有效性并在电子邮件无效时显示警报视图。因此,当我在 alertView 中单击确定按钮时,光标应该转到电子邮件文本字段而不是在电话号码字段中。任何人都可以帮助解决这个问题。
问问题
2138 次
5 回答
2
用于制作任何文本字段的第一响应者。您可以在您的 alertview 委托中执行此操作。
[yourTxtField 成为FirstResponder];
于 2013-06-04T10:21:26.957 回答
1
您可以设置 AlertView 的委托并单击“确定”按钮,
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
[txtEmail becomeFirstResponder]; // your "Email" textField will get focused
}
}
试试这种方式.. HTH :)
于 2013-06-04T10:19:45.850 回答
1
在 alertview 的委托方法中,
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if([alertView isEqual:emailAlert])//emailAlert should be the instance variable
{
if(buttonIndex == 0)//assumes ok button index is 0
{
[textfield becomeFirstResponder];
}
}
}
于 2013-06-04T10:21:16.640 回答
1
让您的视图控制器实现UIAlertViewDelegate
,并将当前类作为委托添加到显示的警报视图。在– alertView:clickedButtonAtIndex:
使电话文本字段中,让第一响应者辞职,并使电子邮件文本字段成为第一响应者。
于 2013-06-04T10:21:27.467 回答
1
确保您的课程符合 UIAlertViewDelegate 协议并显示警报,如
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Your Message" delegate:self cancelButtonTitle:@"cancel " otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
实现委托方法,如
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 0)//ok button index is 0
[textFieldEmail becomeFirstResponder];
}
于 2013-06-04T11:07:10.413 回答