2012-05-20 51 views
0

我已经搜索了一些方法,一旦点击了警报视图上的按钮,我就可以转到新页面。我必须使用prepareForSegue方法吗?或者有没有更简单的方法?尝试转移到新的UIView一旦在AlertView中单击了“登录”按钮

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ 

    if(buttonIndex ==0){ 
     //code goes here 
    } 

    if(buttonIndex ==1){ 
     NSString *username = [[alertView textFieldAtIndex:0] text]; 
     NSString *password = [[alertView textFieldAtIndex:1] text]; 
     NSLog(@"Username:%@",username); 
     NSLog(@"Password:%@",password); 

     //Check if username and password tally if tally move on to Menu page 
     MainPageViewController *anotherController = [[MainPageViewController alloc] initWithNibName:@"AnotherView" bundle:nil]; 

     [self.navigationController pushViewController:anotherController animated:YES]; 
    } 
} 

回答

0

你必须使用alertview委托方法 - alertView:clickedButtonAtIndex:知道哪个按钮被点击,你可以在同一个进行后续操作。

+0

嗨,非常感谢。我使用了alertview委托方法来查看哪个按钮被点击。当点击一个特定的按钮时,我有问题移动到下一个UIView。对。提前致谢.. – user1405928

相关问题