Daniel Christmas
Daniel Christmas

Reputation: 27

UIScrollView Help

Is there a way to put several UIViews In a UIScrollView in a tabbar page. If so, how would I do that? To make it simple, Imageine the homescreen icons on the springboard. Each page is a UIView. I want to basically put this on a tabbar page. Is this possible? How would I do it?

Upvotes: 0

Views: 265

Answers (1)

Aravindhan
Aravindhan

Reputation: 15628

NOTE: First try to accept the answers then only you will get lot of good answer from our seniors.....

first create the uiscrollview and then add that it to the tabbar... for creating the 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];  

Upvotes: 1

Related Questions