当我尝试显示一个刷新按钮作为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