首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >双UIAlertView

双UIAlertView
EN

Stack Overflow用户
提问于 2015-01-06 02:42:10
回答 1查看 65关注 0票数 1

我有两个UIAlertview,当我点击内部时,我想转到不同的页面,我创建两个xib文件,并在主视图控制器中导入它们,但是不知道为什么不能显示它们,当我检查~这里是我的代码时,这不是错误的标志:

代码语言:javascript
复制
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"LP01;" message:@"No Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Help", nil];


UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"LP01;" message:@"No Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Help", nil];




- (void)alert:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex {


            if (buttonIndex == 1) {

        AViewController *switch1 = [[AViewController alloc]
                                   initWithNibName:nil bundle:nil];
        [self presentViewController:switch1 animated:YES completion:NULL];

            }
}

- (void)alert1:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex {



    if (buttonIndex == 1) {


        BViewController *switch2 = [[BViewController alloc]
                                    initWithNibName:nil bundle:nil];
        [self presentViewController:switch2 animated:YES completion:NULL];

    }
}

请帮忙,谢谢~

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-12 05:39:45

代码语言:javascript
复制
UIAlertView *firstAlert = [[UIAlertView alloc] initWithTitle:@"LP01;" message:@"No Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Help", nil];


UIAlertView *secondAlert = [[UIAlertView alloc] initWithTitle:@"LP01;" message:@"No Connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Help", nil];

//记住,对于与它相关的任何元素,代表方法都是相同的。因此,无论您有2、3或5 UIAlertView的you委托方法,只编写一次。

代码语言:javascript
复制
- (void)alert:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex {
    if(alertview == firstAlert){



            AViewController *switch1 = [[AViewController alloc]
                                        initWithNibName:nil bundle:nil];
            [self presentViewController:switch1 animated:YES completion:NULL];


    }
    else if(alertview == secondAlert){



            BViewController *switch2 = [[BViewController alloc]
                                        initWithNibName:nil bundle:nil];
            [self presentViewController:switch2 animated:YES completion:NULL];


    }
}

//不要忘记调用firstAlert显示;或secondAlert显示;以显示您的警报

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27791324

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档