- 1.tableView 本地筛选,cell刷新时候出现如图的bug,注:cell只有一个时候,才会出现这个bug,如果不用延时,
setContentOffset:CGPointZero
代码无效
[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];
});
- 2.push到一个或者多个VC,返回回到指定首页,如图,注意:不是回到我的界面,而是发现
TabBarItem
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];
});
- 4.延迟加载,保证
rootViewController
一定有值
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
_ = delay(0.3) {
if let rootVC = UIApplication.shared.keyWindow?.rootViewController {
Helper.showStandardNoDismissDialog(viewController: rootVC, title: "请务必允许推送", message: "保证第一时间获取工单的反馈") {
//aliyun移动推送
self.initCloudPush()
}
}
}
}
- 5.使用便利方法初始化控制器,返回值不能保证立即的,为保证
controller
一定有值,可以延时调用
convenience init(price: String,completion: @escaping ((String) -> Void)) {
self.init(type: .freePay,title:nil, text: price, completion: nil)
self.freePayBlock = completion
}
let popupVC = DXPopupDialog.init(price: price, completion: completions)
_ = delay(0.1) {
viewController.present(popupVC, animated: true, completion: nil)
}