设置状态栏样式
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
状态栏加载指示器
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
设置屏幕常亮
[UIApplication sharedApplication].idleTimerDisabled = YES;
[UIApplication sharedApplication].idleTimerDisabled = NO;
禁用侧滑返回
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
//或
self.navigationController.navigationItem.leftBarButtonItem = nil;
可滑动或拖动的视图与侧滑返回手势冲突
自定义该视图,并重写gestureRecognizerShouldBegin
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
return NO;
}
开启一个定时器
__weak typeof(self) weakSelf = self;
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
self.timer = timer;
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
dispatch_source_set_event_handler(timer, ^{
});
dispatch_resume(timer);
销毁定时器
dispatch_source_cancel(self.timer);
从子线程中回到主线程
dispatch_async(dispatch_get_main_queue(), ^{
});