2016-09-22 17 views
0

在XIB中它對我來說工作得很好。iOS - 如何將視圖預加載到故事板中的內存?

ThirdViewController *thirdVC = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil]; 

// preload views to the memory 
[thirdVC view]; 

// setup fromviews array and toviews array 
NSArray *fromViews = [NSArray arrayWithObjects:self.imageView1, self.imageView2, self.label1, nil]; 
NSArray *toViews = [NSArray arrayWithObjects:thirdVC.imageView1, thirdVC.imageView2, thirdVC.label1, nil]; 

[self pushViewController:thirdVC fromViews:fromViews toViews:toViews duration:1.0]; 

但是,當我預覽視圖到故事板中的內存,我不知道我該如何使用它。

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"FourthVC" bundle:nil]; 
FourthVC *vc = [sb instantiateViewControllerWithIdentifier:@"FourthVC"]; 

NSArray *fromViews = [NSArray arrayWithObjects:self.imageView1, self.imageView2, self.label1, nil]; 

NSArray *toViews = [NSArray arrayWithObjects:vc.imageView1, vc.imageView2, vc.label1, nil]; 

[self pushViewController:vc fromViews:fromViews toViews:toViews duration:1.0]; 

任何人都可以建議我如何預加載故事板中的視圖?

+0

什麼問題?你的代碼看起來正確?強制通過'[vc view]調用'viewDidLoad''但不知道爲什麼你需要在故事板中的 – Tj3n

+0

m不能訪問陣列m中的對象將xib移動到故事板。 –

+0

你的問題不清楚。你在你的問題中發佈的第二塊代碼是什麼問題? – rmaddy

回答

0

我得到了答案感謝@ Tj3n

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"FourthVC" bundle:nil]; 
FourthVC *vc = [sb instantiateViewControllerWithIdentifier:@"FourthVC"]; 

// preload views to the memory 
[vc view]; 

NSArray *fromViews = [NSArray arrayWithObjects:self.imageView1, self.imageView2, self.label1, nil]; 

NSArray *toViews = [NSArray arrayWithObjects:vc.imageView1, vc.imageView2, vc.label1, nil]; 

[self pushViewController:vc fromViews:fromViews toViews:toViews duration:1.0]; 
相關問題