在我的iPad應用程序。我正在研究UIPageViewController我想在一個頁面上設置文本,在另一個頁面上設置圖像。我嘗試了很多並使用Google搜索,但我沒有找到任何解決方案。這是在浪費我的時間,所以如果有任何人在工作,請指導我併發布示例代碼。如何在UIPageViewController的另一個頁面設置文本和圖像
我已經使用其中有在下面鏈路
http://www.ioslearner.com/implementing-uipageviewcontroller-programatically-without-storyboarding/
這裏是示例代碼的代碼。我用contentviewcontroller。
我想如果我深知然後加入ContentPageView.xib文件中的ImageView,使的出口使用兩個視圖控制器與UIPageViewController
- (UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController
spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation
{
if(UIInterfaceOrientationIsPortrait(orientation))
{
//Set the array with only 1 view controller
UIViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:currentViewController];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
//Important- Set the doubleSided property to NO.
self.pageViewController.doubleSided = NO;
//Return the spine location
return UIPageViewControllerSpineLocationMin;
}
else
{
NSArray *viewControllers = nil;
ContentViewController *currentViewController = [self.pageViewController.viewControllers objectAtIndex:0];
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)currentViewController labelContents]];
NSUInteger currentIndex2 = [self.imagesArray2 indexOfObject:[(ContentViewController *)currentViewController imageContents]];
if(currentIndex == 0 || currentIndex %2 == 0 || currentIndex2 == 0||currentIndex2 %2 == 0)
{
UIViewController *nextViewController = [self pageViewController:self.pageViewController viewControllerAfterViewController:currentViewController];
viewControllers = [NSArray arrayWithObjects:currentViewController, nextViewController, nil];
}
else
{
UIViewController *previousViewController = [self pageViewController:self.pageViewController viewControllerBeforeViewController:currentViewController];
viewControllers = [NSArray arrayWithObjects:previousViewController, currentViewController, nil];
}
//Now, set the viewControllers property of UIPageViewController
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
return UIPageViewControllerSpineLocationMid;
}
}
請發表您已經到目前爲止已經試過代碼。 ... – Mohammad 2013-02-15 09:47:33
你如何設置文字和圖像? – fibnochi 2013-02-15 09:50:46
我已經用我在代碼中使用的鏈接編輯了這個問題。請通過它。 – Goutham 2013-02-15 09:54:59