我在 ViewDidLoad 中创建了一个 UIAlertView,如下所示:
prompt = [[UIAlertView alloc] init];
prompt.title = @"تسجيل الدخول";
prompt.message = @"\n\n\n";
prompt.delegate = self;
[prompt addButtonWithTitle:@"الغاء"];
[prompt addButtonWithTitle:@"دخول"];
userNameTxtField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 50.0, 260.0, 25.0)];
[userNameTxtField setBackgroundColor:[UIColor whiteColor]];
[userNameTxtField setPlaceholder:@"اسم المستخدم"];
[prompt addSubview:userNameTxtField];
passwordTxtField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 85.0, 260.0, 25.0)];
[passwordTxtField setBackgroundColor:[UIColor whiteColor]];
[passwordTxtField setPlaceholder:@"كلمة المرور"];
[passwordTxtField setSecureTextEntry:YES];
[prompt addSubview:passwordTxtField];
[prompt show];
//[prompt release];
// set cursor and show keyboard
[userNameTxtField becomeFirstResponder];
clickedButtonAtIndex 函数如下:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex ==0) {
NSLog(@"cancel");
}else {
NSLog(@"will login isA");
}
}
但是当我单击任何按钮时,我会看到输出,然后应用程序崩溃并给我以下异常:
[MaktabatyTableViewController respondsToSelector:]: message sent to deallocated instance 0x894cfa0
有什么帮助吗???