當我嘗試顯示一個刷新按鈕作爲rightBarButtonItem時,我有一個奇怪的問題。RightBarButtonItem只顯示爲不活動
總之,我已經實現了它,但運行應用程序時看不到任何東西。但是,當我點擊故事板Debug --> View Debugging --> Capture View Hierarchy
。我可以看到一個看起來無效且隱藏的刷新按鈕。我不知道爲什麼。
的viewcontrol通過自定義pageviewcontroller實際上推入。
- (void)viewDidLoad {
[super viewDidLoad];
self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pageController.dataSource = self;
[[self.pageController view] setFrame:[[self view] bounds]];
TNViewController *initialViewController = [self viewControllerAtIndex:currentIndex];
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self action:@selector(refreshClicked:)];
initialViewController.navigationItem.rightBarButtonItem = refreshButton;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:initialViewController];
NSArray *viewControllers = [NSArray arrayWithObject:navigationController];
[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];
[self.pageController didMoveToParentViewController:self];
for (UIView *subview in self.pageController.view.subviews) {
if ([subview isKindOfClass:[UIPageControl class]]) {
UIPageControl *pageControl = (UIPageControl *)subview;
pageControl.pageIndicatorTintColor = [UIColor blackColor];
pageControl.currentPageIndicatorTintColor = [utils colorFromHexString:@"#AA3635"];
pageControl.numberOfPages = _news.count;
pageControl.backgroundColor = [UIColor whiteColor];
}
}
self.edgesForExtendedLayout = UIRectEdgeTop;
}
我錯過了什麼?
但我利用在首位右一個UINavigationController?爲什麼我應該手動添加這些?我仍然沒有任何運氣給它一槍。 – Houman