I am trying to add different views on the pages of a uipagecontroller.Have total of three pages.That is in the first page i have to implement a map,in the second view,a simple view with some labels and the in the third view,a table.I followed the tutorial available here : http://developer.apple.com/library/ios/#samplecode/PageControl/Introduction/Intro.html for implementing the page controller.How can i set the views of this controller based on the selected page.?Can anyone give some idea?I tried with this method.But it didn't give any way
- (void)loadScrollViewWithPage:(int)page {
NSLog(@"%d",page);
if (page < 0)
return;
if (page >= kNumberOfPages)
return;
// replace the placeholder if necessary
MyViewController *controller = [viewControllers objectAtIndex:page];
if ((NSNull *)controller == [NSNull null])
{
controller = [[MyViewController alloc] initWithPageNumber:page];
[viewControllers replaceObjectAtIndex:page withObject:controller];
[controller release];
}
// add the controller's view to the scroll view
if (controller.view.superview == nil)
{
CGRect frame = scroll.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
controller.view.frame = frame;
[scroll addSubview:controller.view];
}
}
将所需的视图添加到scrollView Object,然后可以使用以下代码来管理所有视图: https : //github.com/SIMHAM/DDPageControl
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.