在我的iPad应用中。我正在研究UIPageViewController我想在一个页面上设置文本,在另一个页面上设置图像。我已经尝试了很多并用Google搜索,但我找不到任何解决方案。这是在浪费我的时间,所以如果有人参与其中,请指导我并发布示例代码。
我使用了以下链接中的代码
http://www.ioslearner.com/implementing-uipageviewcontroller-programatically-without-storyboarding/
这是示例代码。我使用了contentviewcontroller。
我想使用两个带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;
}
}
答案 0 :(得分:1)
如果我理解得很好,那么在ContentPageView.xib文件中添加一个imageView并制作一个插座。将ImageView和标签设置为隐藏或显示在您所需的页面上。
答案 1 :(得分:0)
以下步骤可能会有所帮助
if ([myObject class] == [UIImage class])
{
//HERE ASSIGN IT TO UIIMAGEVIEW.image
}
else
{
//HERE ASSIGN IT TO UILABEL.text
}
对不起,如果这不是你想要的......