我已经实现了带有文本字段的警报视图代码,当我单击“确定”按钮时,文本字段输入的值存储在字符串格式中作为(str)并且我将该值添加到数组中以便我将数组加载到表视图但是这里的问题是每个时间表视图都包含一个项目,但我想存储多个项目,从警报输入项目并将其保存为数组项目如何实现通过警报视图保存多个数组项目的代码任何人都可以帮助我在 iphone 中解决这个问题.
myAlert = [[UIAlertView alloc] initWithTitle:@"Enter year"
message:@"alert message"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
[myAlert addTextFieldWithValue:@"" label:@"entervalue"];
alertTextField=[myAlert textFieldAtIndex:0];
alertTextField.keyboardType=UIKeyboardTypeAlphabet;
alertTextField.clearsOnBeginEditing=YES;
alertTextField.clearButtonMode=UITextFieldViewModeWhileEditing;
alertTextField.keyboardAppearance=UIKeyboardAppearanceAlert;
[myAlert show];
[myAlert release];
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *buttonTitle=[alertView buttonTitleAtIndex:buttonIndex];
if ([buttonTitle isEqualToString:@"Ok"]) {
str = alertTextField.text;
[savedarray addObject:str];
}
}