2

使用我确保[alertView show];正在调用的调试器,但对话框不可见,我还需要做什么才能显示它?

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    if( [[userInfo objectForKey:@"aps"] objectForKey:@"alert"] != NULL)
    {
        NSString *msg = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];
        if(msg != nil) {
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Usage Alert"
            message:msg  delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
            [alertView show];
        }
    }
}
4

2 回答 2

2

在您的视图控制器 .h 文件中,您需要<UIAlertViewDelegate>在打开的花括号之前声明 Like this,用大于和小于符号封装:

#import <UIKit/UIKit.h>

@interface YourViewControllersName : UIViewController <UIAlertViewDelegate> {

   // your variable declarations are here...
}

 // your method declarations are here...
于 2013-01-30T00:00:40.243 回答
0

对不起大家,这原来是我的编译器/xCode 没有真正识别我输入的代码或类似的东西的问题,环境被破坏了。

于 2013-01-30T01:56:34.993 回答