我是 iPhone 开发人员的新手,
我想一个接一个地实现 2 个警报视图,比如当用户按下删除按钮时,第一个警报视图会Are you sure want to Delete ?
用两个按钮询问yes
和no
现在,如果用户按下yes
,则第二个警报视图将带有消息,Deleted Successfully !
此警报视图仅包含OK
按钮,现在单击此OK
按钮我想调用一种方法。
如果用户按下No
,那么什么都不会发生,警报应该消失。
这是我的代码片段,
-(void)DeletebtnCliked:(id)sender
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Are you sure want to delete ?"
message:nil delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Yes",@"No",nil];
[alertView show];
[alertView release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
UIAlertView* alertew = [[UIAlertView alloc] initWithTitle:@"Deleted Successfully !"
message:nil delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertew show];
[alertew release];
if (buttonIndex == 0)
{
[self MethodCall];
}
}
else if (buttonIndex == 1)
{
[alertView dismissWithClickedButtonIndex:1 animated:TRUE];
}
}
写完这段代码后,我进入了无限循环。
任何帮助将不胜感激。