复制粘贴iOS 开发 iOS开发

iOS用延时dispatch_after解决bug示例

2016-06-23  本文已影响2679人  船长_
demo2.gif
[self.tableView reloadData];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            
     [self.tableView setContentOffset:CGPointZero animated:YES];
});
demo.gif
UITabBarController *vc=self.tabBarController;
[self backAction:^{
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [vc setSelectedIndex:1];
    });
}];
// 延迟加载窗口,保证创建的这个窗口在所有窗口的最上面
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
      window_ = [[UIWindow alloc] init];
});
上一篇下一篇

猜你喜欢

热点阅读