我在我的应用程序中需要输入提示,我已经尝试过了
// Create a new item UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"New item" message:@"Enter a name for the item" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil]; alert.alertViewStyle = UIAlertViewStylePlainTextInput; [alert show];
然后像这样处理它:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ // The user created a new item, add it if (buttonIndex == 1) { // Get the input text NSString *newItem = [[alertView textFieldAtIndex:0] text]; } }
但它看起来不像clickedButtonAtIndex被调用,为什么?
亲切的问候,Erik