在我的iPad应用程序中。我正在使用UIPageViewController,我想在一个页面上设置文本,在另一页面上设置图像。我已经尝试了很多,并且用谷歌搜索,但是没有找到任何解决方案。这很浪费我的时间,所以如果有人为此工作,请指导我并发布示例代码。
我已经使用了下面链接中的代码
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;
}
}
最佳答案
以下步骤可能会有所帮助
if ([myObject class] == [UIImage class])
{
//HERE ASSIGN IT TO UIIMAGEVIEW.image
}
else
{
//HERE ASSIGN IT TO UILABEL.text
}
如果您需要更多帮助,请发帖。
抱歉,这不是您想要的.....
关于iphone - 如何在UIPageViewController中在一页上设置文本并在另一页上设置图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14891867/