1. 去掉BackBarButtonItem的文字
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault];
2.判斷是否是點(diǎn)擊HOME鍵進(jìn)入后臺(tái)還是點(diǎn)擊了鎖屏鍵鍵入后臺(tái)
static void displayStatusChanged(CFNotificationCenterRef center,void *observer,CFStringRef name,const void *object, CFDictionaryRef userInfo){ if (name == CFSTR("com.apple.springboard.lockcomplete")) { [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"kDisplayStatusLocked"]; [[NSUserDefaults standardUserDefaults] synchronize]; } 放進(jìn)方法: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, displayStatusChanged, CFSTR("com.apple.springboard.lockcomplete"), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); 放進(jìn)方法:- (void)applicationDidEnterBackground:(UIApplication *)application UIApplicationState state = [[UIApplication sharedApplication] applicationState]; if (state == UIApplicationStateInactive) { NSLog(@"Sent to background by locking screen"); } else if (state == UIApplicationStateBackground) { if (![[NSUserDefaults standardUserDefaults] boolForKey:@"kDisplayStatusLocked"]) { NSLog(@"Sent to background by home button/switching to other app"); } else { NSLog(@"Sent to background by locking screen"); } } 放進(jìn)方法:- (void)applicationWillEnterForeground:(UIApplication *)application [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"kDisplayStatusLocked"]; [[NSUserDefaults standardUserDefaults] synchronize];