2011-02-12 25 views
2

我有廈門國際銀行文件,一個滾動型和4 UIviewcontrollers現在我想加4個viewcontrollers以滾動型的UIScrollView多UIViewControllers

,也是滾動四個viewcontrollers

任何一個啓用知道這PLZ回答問題

回答

9

只需添加它們即可。有什麼問題?

// this loads a view controller from a nib 
controller = [[UIViewController alloc] initWithNibName:@"YourNibsName" bundle:nil]; 

// this adds the viewcontroller's view to the scrollview 
[scrollView addSubview:controller.view]; 

// place the subview somewhere in the scrollview 
CGRect frame = controller.view.frame; 
frame.origin.x = 600; 
controller.view.frame = frame; 

// don't forget to release the viewcontroller somewhere in your dealloc 
[controller release]; 

對所有的四個控制器都這樣做。

+0

感謝ü這個 – user564963 2011-02-12 11:20:32

+0

但滾動未啓用四個viewcontrollers PLZ告訴我如何處理四個viewcontrollers在這個滾動屬性 – user564963 2011-02-12 11:21:15

3

是的,你可以添加viewcontrollers的意見,你的滾動視圖,但要記住,你正在自己等同於一個的UITabBarController或UINavigationController的,所以你有一定的責任:

當你的alloc初始化你vc從一個nib vc將得到其調用的viewDidLoad方法。

但是,當你把vc.view放到你的滾動視圖中時,你需要調用[vc viewDidAppear:YES](並且如果你的vc使用它,也調用viewWillAppear)。

請注意諸如從vc展示模態視圖控制器的事情,因爲這可能無法按預期工作。

彼得