首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >objective c- derived UIAlertView OK按钮

objective c- derived UIAlertView OK按钮
EN

Stack Overflow用户
提问于 2012-06-14 21:40:20
回答 1查看 778关注 0票数 0

我有一些常规的警报视图和一个名为' UINotificationAlertView‘的自定义警报视图,我希望自定义UINotificationAlertView上的'ok’按钮单击事件使用第二种方法,而不是第一种方法。我该怎么做呢?我是objective c的新手,如果这是一个愚蠢的问题,我很抱歉。

代码语言:javascript
复制
UINotificationAlertView *message = [[UINotificationAlertView alloc]
                                    initWithTitle:@""
                                    message:row.alertBody
                                    delegate:self.
                                    cancelButtonTitle:@"OK"                      
                                    otherButtonTitles:nil];

App delgate中的两种方法:

代码语言:javascript
复制
//UIAlertView delegate
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

        if(buttonIndex == kNo) {
        } else {
            //Close by suspending...
            [[UIApplication sharedApplication] suspend];
        }
    }
    - (void)alertNotificationView:(UINotificationAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
        NSLog(@"phils new delegate");
        if(buttonIndex == kNo) {
        } else {
            //Close by suspending...
            [[UIApplication sharedApplication] suspend];
        }
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-06-14 21:52:16

试一试

在.h文件中,输入:

代码语言:javascript
复制
@interface YourClassName : UIViewController<UIAlertViewDelegate>

在.m文件中:

message.delegate = self;

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

https://stackoverflow.com/questions/11034369

复制
相关文章

相似问题

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