当我选择特定索引处的任何单元格时,我有一个表视图,然后调用didSelectRowAtIndexPath方法
但是每次打开应用程序时第一次需要5到6秒的时间来初始化下一个VC
M没有对下一个vc的viewwillappear进行任何大型处理
我的didselect方法代码:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
dispatch_async(dispatch_get_main_queue()) { () -> Void in
let obj: NewService = self.storyboard!.instantiateViewControllerWithIdentifier("AddService") as! NewService
print("delay 0")
let casell: Case = self.caseList[indexPath.row]
print("delay 1")
obj.caseNo = String(casell.CasesID)
print("delay 2")
obj.indexNo = (indexPath.row)
print("delay 3")
navigationController!.pushViewController(obj, animated: true)
print("delay 4")
}
我的下一个添加服务的vc有这个:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"delay 5");
myServiceList = [[NSUserDefaults standardUserDefaults] valueForKey:@"serviceList"];
alert = [[UIAlertView alloc] init];
self.txtvwDesc.layer.borderWidth = 0.5f;
self.txtvwDesc.layer.cornerRadius = 4.0;
self.txtDate.layer.borderWidth = 0.5f;
self.txtDate.layer.cornerRadius = 4.0;
self.txtMinute.layer.borderWidth = 0.5f;
self.txtMinute.layer.cornerRadius = 4.0;
self.title = [@"Case No : " stringByAppendingString: self.caseNo];
// self.title = @"Moin";
self.btnservice.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
[self.txtDate setDropDownMode:IQDropDownModeDatePicker];
NSLog(@"delay 6");
});
}