使用调试器我确保调用了[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];
}
}
}
答案 0 :(得分:2)
在你的视图控制器.h文件中,你需要声明<UIAlertViewDelegate>
这样,在开始花括号之前,用大于和小于符号封装:
#import <UIKit/UIKit.h>
@interface YourViewControllersName : UIViewController <UIAlertViewDelegate> {
// your variable declarations are here...
}
// your method declarations are here...
答案 1 :(得分:0)
对不起大家来说,这对我的编译器/ xCode来说是一个问题,实际上并没有认识到我放入的代码或者其他类似的东西,环境被破坏了。