111*_*110 11 iphone objective-c uialertview
我有控制器实现UIAlertViewDelegate.在实施中,我有:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
Run Code Online (Sandbox Code Playgroud)
方法.当我创建UIAlertView时,我将'委托'放到'self'中,它运行正常.但问题是,现在我还有一个警报视图,我希望每个视图都有不同的行为.那么如何检查哪个alertView发送消息?
Vla*_*mir 12
UIAlertView是一个UIView子类,因此有标签属性可用于区分它们:
UIAlertView *alert1 = ... //Create alert
alert1.tag = kActionTag1;
//show alert
...
UIAlertView *alert2 = ... //Create alert
alert2.tag = kActionTag2;
//show alert
Run Code Online (Sandbox Code Playgroud)
然后在委托方法中:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (alertView.tag == kActionTag1){
// Perform 1st action
}
if (alertView.tag == kActionTag1){
// Perform 2nd action
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2322 次 |
最近记录: |