我有一个UIViewController
调用单个对象上的方法,在给定某个条件的情况下,它会显示UIAlertView
。当用户点击UIAlertView
中的按钮时,我希望UIAlertView
消失(此时它会消失),然后在其后面的UIViewController
切换到另一个场景。我的问题是UIAlertView
来自单例类,而segue需要在UIViewController
上执行。
在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
是时候做了一段时间了?
答案 0 :(得分:0)
'通知'是一个好词。 :)我建议视图控制器监听单例将在发生segue时发布的NSNotification。然后perform...
代码将移动到响应通知而调用的视图控制器方法中。