iOS:对 <UITableViewController> 的开始/结束外观转换的不平衡调用
<p><p>我有一个 <code>UIPageViewController</code>,我在其中动态创建了 3 个 <code>UITableViewController</code>。 </p>
<p>!!!!!!仅当我使用 <code>"Partial Curl"</code> 过渡样式时才会出现此问题。</p>
<p>如果我滚动我的 <code>UIPageViewController</code> 太快,我会收到以下错误消息:</p>
<blockquote>
<p>"Unbalanced calls to begin/end appearance transitions for
".</p>
</blockquote>
<p>我像这样创建我的 <code>UITableViewController</code>:</p>
<pre><code>- (void)createTable {
CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
_tableViewController1 = [ init];
_tableViewController2 = [ init];
_tableViewController3 = [ init];
_tableViewController1.tableView.frame = frame;
_tableViewController2.tableView.frame = frame;
_tableViewController3.tableView.frame = frame;
_tableViewController1.tableView.backgroundColor = ;
_tableViewController2.tableView.backgroundColor = ;
_tableViewController3.tableView.backgroundColor = ;
_viewControllersArray = @;
direction:UIPageViewControllerNavigationDirectionForward
animated:NO completion:nil];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
NSUInteger currentIndex = ;
currentIndex--;
if (currentIndex == -1) {
currentIndex = 2;
;
}
return ;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
NSUInteger currentIndex = ;
currentIndex++;
if (currentIndex == 3) {
currentIndex = 0;
;
}
return ;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>问题在于初始化尚未完成,但它会进入下一页。你应该添加一个标志来监控动画过程。</p>
<pre><code>- (void)pageViewController:(UIPageViewController *)pageViewController didFinishAnimating:(BOOL)finished previousViewControllers:(NSArray<UIViewController *> *)previousViewControllers transitionCompleted:(BOOL)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;
}
</code></pre></p>
<p style="font-size: 20px;">关于iOS:对 <UITableViewController> 的开始/结束外观转换的不平衡调用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/32651708/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/32651708/
</a>
</p>
页:
[1]