2011-04-07 51 views
0

有沒有一種方法可以將多個UIViews放在一個UIScrollView的tabbar頁面中。如果是這樣,我該怎麼做?爲了簡單起見,Imageine在跳板上顯示主屏幕圖標。每個頁面都是一個UIView。我想基本上把它放在一個tabbar頁面上。這可能嗎?我會怎麼做?UIScrollView幫助

回答

1

注: 首先嚐試接受的答案,那麼只有你會得到很多從我們的前輩好答案的.....

首先創建的UIScrollView,然後添加它的TabBar ...的創建uiscrollview

UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)]; 
scroll.pagingEnabled = YES; 
NSInteger numberOfViews = 3; 
for (int i = 0; i < numberOfViews; i++) { 
CGFloat yOrigin = i * self.view.frame.size.width; 
UIView *awesomeView = [[UIView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
awesomeView.backgroundColor = [UIColor colorWithRed:0.5/i green:0.5 blue:0.5 alpha:1]; 
[scroll addSubview:awesomeView]; 
[awesomeView release]; 
}  
scroll.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height); 
[self.view addSubview:scroll];