使用调试器,我确保已调用[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];
}
}
}
最佳答案
在视图控制器.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/