0

我有一个主视图,当单击它再次转到另一个视图时,我将转到另一个视图。当单击该视图上的一个按钮时,将出现一个模态视图,然后单击每个模态视图时会出现另外 3 个模态视图。当单击最终的模态视图会出现一个警报,当单击该警报时,我想显示根主视图。这可能吗?

4

4 回答 4

1

使用给定的代码片段显示 AlertView:

UIAlertView* alert = [[UIAlertView alloc] initWithTitle:title message:@"Alert Message" delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [警报显示];[警报发布];

委托方法实现:

  • (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { [self.navigationController popToRootViewControllerAnimated:YES];

}

于 2012-08-27T12:14:44.500 回答
0

示例代码如下:

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Alert Message?" message:@"Error......" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK"] autorelease];
[alert show];

下面给出了实现alertView的委托函数

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        //cancel clicked ...do your action
    }
    else if (buttonIndex == 1)
    {
        //OK clicked
         [self.navigationController popToViewController animated:YES];
    }
}
于 2012-08-27T12:07:06.693 回答
0
int c=[self.navigationController.viewControllers count]-4;
            [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:c] animated:YES];
于 2012-08-27T12:13:47.120 回答
0

只需在.h文件中给出委托,然后在alertview的委托方法中编写下面的代码..

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 1) {
            [self.navigationController popToRootViewControllerAnimated:YES];///this line is important..
    }
    else{
      // do your action...
     }
}

我希望这个答案对你有用..

:)

于 2012-08-27T12:16:25.030 回答