2012-04-06 101 views
0

我有一个UIViewController,它调用一个单例对象上的方法,其中在给定的条件下显示UIAlertView。当用户点击UIAlertView中的按钮时,我想让UIAlertView消失(现在是它),然后是UIViewController,然后继续播放到另一个场景。我的问题是UIAlertView来自singleton类,而segue需要在UIViewController上执行。从另一个类中调用一个类中的segue

Singleton.m

-(void)alertView:(UIAlertView *)alertView 
clickedButtonAtIndex:(NSInteger)buttonIndex { 
    NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex]; 
    if ([buttonTitle isEqualToString:@"Button!"]) { 
     [self performSegueWithIdentifier: @"Segue!" sender: self]; 
    } 
} 

我的问题是什么我替换self用,让我通知UIViewController,它的时间做SEGUE?

回答

0

'通知'是个好词。 :)我建议让视图控制器监听一个NSNotification,这个单例会在需要继续发生时发布。然后perform...代码将移入为响应通知而调用的视图控制器方法。

+0

谢谢,完美的工作!我完全不熟悉'NSNotification's,所以我只是看了一个关于如何使用它们的快速教程,并且你的想法奏效了!再次感谢:D – 2012-04-06 04:54:42