使用调试器,我已确保[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];
}
}
}
最佳答案
在 View Controller .h 文件中,您需要声明 <UIAlertViewDelegate>
像这样,在左大括号之前,用大于和小于符号封装:
#import <UIKit/UIKit.h>
@interface YourViewControllersName : UIViewController <UIAlertViewDelegate> {
// your variable declarations are here...
}
// your method declarations are here...
关于iphone - AlertView 正在运行,但未显示 didReceiveRemoteNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14593874/