awl*_*lcs 3 iphone uialertview ipad
我有一个2 UIAlert显示我按下按钮.我希望第二个警报仅在我们按下第一个OK按钮时第一个UIAlert被解除时才可见.
我该怎么办?以下是我的代码:
- (IBAction)button:(id)sender {
UIAlertView *view;
view = [[UIAlertView alloc]
initWithTitle: @"Message"
message: @"Adding..."
delegate: self
cancelButtonTitle: @"OK" otherButtonTitles: nil];
[view show];
MyAppAppDelegate *appDelegate = (MyAppAppDelegate *)[[UIApplication sharedApplication] delegate];
if (appDelegate.array_presets.count) {
view = [[UIAlertView alloc]
initWithTitle: @"Message"
message: @"limit already reached"
delegate: self
cancelButtonTitle: @"OK" otherButtonTitles: nil];
[view show];
}
[view autorelease];
}
Run Code Online (Sandbox Code Playgroud)
为两个警报视图使用不同的标记.
alertView.tag = 1000;
Run Code Online (Sandbox Code Playgroud)
实现警报视图委托方法并检查标记值.使用第一个警报视图调用委托时,创建并显示第二个警报视图.
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if(alertView.tag == 1000)
{
//first alert view's button clicked
UIAlertView *view = [[UIAlertView alloc]
initWithTitle: @"Message"
message: @"limit already reached"
delegate: self
cancelButtonTitle: @"OK" otherButtonTitles: nil];
view.tag = 2000;
[view show];
}
if(alertView.tag == 2000)
{
//handle second alert view's button action
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2310 次 |
| 最近记录: |