尝试将刷新按钮显示为 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;
}
请问我错过了什么?