
我遇到的问题是,在我的第一个视图控制器的vIEwdIDload方法中,我提出了一个用户在使用应用程序之前必须看到的警报.
在用户从vIEwdIDload方法中看到警报后,如何从我的应用程序委托中调用该方法?
编辑:
所以,正如评论中所建议的那样,我添加了一个全局变量,一旦我从我的VIEwDIDload方法显示警报,我就设置为true,但是我的appDelegate的通知警报仍然没有出现.
这是我的app delegate.m文件:
- (BOol)application:(UIApplication *)application dIDFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ // OverrIDe point for customization after application launch. [Parse setApplicationID:@"xxxxxxxxxxxxxxxx" clIEntKey:@"xxxxxxxxxxxx"]; // Register for Push Notitications,if running iOS 8 if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound); UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categorIEs:nil]; [application registerUserNotificationSettings:settings]; [application registerForRemoteNotifications]; } else { // Register for Push Notifications before iOS 8 [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)]; } return YES; NSDictionary *notificationPayload = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]; if (Notification == true) { if (![pushText isEqual: @""]) { pushText = [[notificationPayload objectForKey:@"aps"] objectForKey:@"alert"]; UIAlertVIEw *alert_news = [[UIAlertVIEw alloc] initWithTitle:NSLocalizedString(@"News","") message:pushText delegate:nil cancelbuttonTitle:@"Ok" otherbuttonTitles: nil]; [alert_news show]; } }} 这是我的vIEwdIDload方法:
RoadSafetyAppAppDelegate *AppDelegate;- (voID)vIEwDIDLoad{ AppDelegate = (RoadSafetyAppAppDelegate *)[[UIApplication sharedApplication] delegate]; [super vIEwDIDLoad]; // Do any additional setup after loading the vIEw,typically from a nib. backgroundImage.Alpha = 0.3; toRecipIEnts = [[NSArray alloc]initWithObjects:@"records@shellharbour.nsw.gov.au",nil]; static int appCounter; if ( appCounter < 1 ) { UIAlertVIEw *alert = [[UIAlertVIEw alloc] initWithTitle:NSLocalizedString(@"disclaimer","") message:NSLocalizedString(@"Using a mobile phone whilst driving is against the law. Ensure that you are not behind the wheel when using this app.","") delegate:nil cancelbuttonTitle:@"I agree to not use a mobile phone while driving" otherbuttonTitles: nil]; [alert show]; appCounter = appCounter+1; AppDelegate.NotificationAlert = @"1"; AppDelegate.Notification = true; }}解决方法 因为您希望在显示任何通知之前显示免责声明一次,并确保用户在同意按钮上看到并轻敲.你可以使用简单的本地通知来做到这一点. 在委托中(… dIDFinishLaunchingWithOptions 总结
以上是内存溢出为你收集整理的ios – 在显示来自viewDidload的警报之前显示来自app delegate的警报全部内容,希望文章能够帮你解决ios – 在显示来自viewDidload的警报之前显示来自app delegate的警报所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)