App delegate methods aren't being called in iOS 13

前端 未结 3 1819
梦如初夏
梦如初夏 2020-12-07 08:58

I am using Xcode 11 and building an app for iOS 13. In a new project I created in Xcode some of the UIApplicationDelegate methods were missing so I added them back into the

3条回答
  •  萌比男神i
    2020-12-07 09:49

    This thread helped me:

    View controller responds to app delegate notifications in iOS 12 but not in iOS 13

    Objective C:

    if (@available(iOS 13.0, *)) {
        [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(appWillResignActive:) 
              name:UISceneWillDeactivateNotification object:nil];
    
        [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(appDidBecomeActive:) 
              name:UISceneDidActivateNotification object:nil];
    
    }
    else {
        [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(appWillResignActive:) 
              name:UIApplicationWillResignActiveNotification object:nil];
    
    
        [[NSNotificationCenter defaultCenter]addObserver:self
              selector:@selector(appDidBecomeActive:)
              name:UIApplicationDidBecomeActiveNotification
                                                  object:nil];
    }
    

提交回复
热议问题