我有一个 UIPageViewController
,我在其中动态创建了 3 个 UITableViewController
。
!!!!!!仅当我使用 "Partial Curl"
过渡样式时才会出现此问题。
如果我滚动我的 UIPageViewController
太快,我会收到以下错误消息:
"Unbalanced calls to begin/end appearance transitions for ".
我像这样创建我的 UITableViewController
:
- (void)createTable {
CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
_tableViewController1 = [[UITableViewController alloc] init];
_tableViewController2 = [[UITableViewController alloc] init];
_tableViewController3 = [[UITableViewController alloc] init];
_tableViewController1.tableView.frame = frame;
_tableViewController2.tableView.frame = frame;
_tableViewController3.tableView.frame = frame;
_tableViewController1.tableView.backgroundColor = [UIColor greenColor];
_tableViewController2.tableView.backgroundColor = [UIColor redColor];
_tableViewController3.tableView.backgroundColor = [UIColor blueColor];
_viewControllersArray = @[_tableViewController1, _tableViewController2, _tableViewController3];
[self setViewControllers[_tableViewController1]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO completion:nil];
}
- (UIViewController *)pageViewControllerUIPageViewController *)pageViewController viewControllerBeforeViewControllerUIViewController *)viewController{
NSUInteger currentIndex = [_viewControllersArray indexOfObject:viewController];
currentIndex--;
if (currentIndex == -1) {
currentIndex = 2;
[self reloadTableView];
}
return [_viewControllersArray objectAtIndexcurrentIndex)];
}
- (UIViewController *)pageViewControllerUIPageViewController *)pageViewController viewControllerAfterViewControllerUIViewController *)viewController{
NSUInteger currentIndex = [_viewControllersArray indexOfObject:viewController];
currentIndex++;
if (currentIndex == 3) {
currentIndex = 0;
[self reloadTableView];
}
return [_viewControllersArray objectAtIndexcurrentIndex)];
}
问题在于初始化尚未完成,但它会进入下一页。你应该添加一个标志来监控动画过程。
- (void)pageViewControllerUIPageViewController *)pageViewController didFinishAnimatingBOOL)finished previousViewControllersNSArray<UIViewController *> *)previousViewControllers transitionCompletedBOOL)completed{
if (completed || finished)
_pageIsAnimating = NO;
}
-(void)pageViewController:(UIPageViewController *)pageViewController willTransitionToViewControllers:(NSArray<UIViewController *> *)pendingViewControllers{
_pageIsAnimating = YES;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
if (_pageIsAnimating){
return nil;
}
关于iOS:对 <UITableViewController> 的开始/结束外观转换的不平衡调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32651708/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |