【发布时间】:2012-01-24 21:23:12
【问题描述】:
我正在为 UIAlertView 使用 iOS 5 的一项新功能。我像这样创建一个 UIAlertView:
UIAlertView *scanCode = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Some Title", @"") message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:NSLocalizedString(@"OK", @""), nil];
[scanCode setAlertViewStyle:UIAlertViewStylePlainTextInput];
scanCode.tag = 1234;
[scanCode show];
[scanCode release];
我现在使用的委托是:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView.tag == 1234) {
if (buttonIndex == 1)
{
//do something
}
}
}
}
现在我想模拟回车键,所以当用户在键盘上按下回车键时,当按下警报的 OK 按钮时会发生同样的事情。我该怎么做?
提前致谢!
【问题讨论】: