我正在用兩頁創建一個簡單的UIPageViewController,如何顯示脊柱?目前中間沒有任何東西。外邊界也不見了。如何在uipageviewcontroller中顯示脊椎?
這是UIPageViewController
//
// PageViewController.m
// pageuiviewproject
//
//
#import "PageViewController.h"
#import "contentViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface PageViewController()
@property (nonatomic, strong) UIPageViewController *pageViewController;
@end
@implementation PageViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageViewController.delegate = self;
self.pageViewController.dataSource = self;
NSArray *viewControllers = [NSArray arrayWithObject:[[contentViewController alloc]init]];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
self.pageViewController.view.layer.borderColor = [UIColor blackColor].CGColor;
self.pageViewController.view.layer.borderWidth = 3.0f;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UIPageViewController delegate methods
-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
return [[contentViewController alloc] init];
}
-(UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
return [[contentViewController alloc] init];
}
-(UIPageViewControllerSpineLocation)pageViewController:(UIPageViewController *)pageViewController spineLocationForInterfaceOrientation:(UIInterfaceOrientation)orientation{
NSArray *viewControllers = [NSArray arrayWithObjects:[[contentViewController alloc] init], [[contentViewController alloc] init], nil];
[self.pageViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:NULL];
self.pageViewController.doubleSided = YES;
return UIPageViewControllerSpineLocationMid;
}
@end
代碼中的contentViewController目前是空的。這是它在模擬器中的樣子... image
我想創建以下外觀mosaic app look。這是一個自定義的外觀?我希望這可以通過設置UIPageViewController屬性來實現。
那麼你希望錯誤。 :(UIPageViewController根本不提供任何「外觀」,它只是顯示連續視圖控制器視圖的一種方式,您在這些視圖中放置的內容或顯示在頁面視圖控制器視圖後面或周圍的內容取決於您。 – matt
謝謝@matt,所以爲了得到像Mosaic圖像的外觀和感覺,我需要放置一個書架UIImageView,並將UIPageViewController放置在uiImageView中,但仍然不知道如何顯示脊椎。 ? –
是的,但你可能只需要在頁面控制器前面放置一些繪圖(一些沒有用戶交互的東西,所以點擊會進入頁面視圖控制器及其視圖)我沒有嘗試過,但是我不能看看它爲什麼不行。 – matt