IOS 8中不推荐使用的代码

问题描述 投票:-3回答:1

我是ios和Objective-c的新手,我从xcode得到了这个警告,并且不知道该怎么做。

willRotateToInterface也没有工作,我也检查了其他问题,但它只有相同的方式来应用它。

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    UIUserNotificationSettings *settings =
    [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert |
     UIUserNotificationTypeBadge |
     UIUserNotificationTypeSound
                                      categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     UIRemoteNotificationTypeAlert |
     UIRemoteNotificationTypeBadge |
     UIRemoteNotificationTypeSound];
}

我收到警告registerForRemoteNotificationTypes:'不推荐使用:首先在iOS 8.0中弃用 - 使用 - [UIApplication registerForRemoteNotifications]和UserNotifications Framework's - [UNUserNotificationCenter requestAuthorizationWithOptions:completionHandler:]

ios objective-c xcode
1个回答
1
投票

请实施以下方法

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{   
    [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context)
    {
        //..... Your code here
    } completion:^(id<UIViewControllerTransitionCoordinatorContext> context)
    { 

    }];

    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
© www.soinside.com 2019 - 2024. All rights reserved.