2012-05-22 178 views
0

我有一个视图,我提出了两个不同的uiwebviews(从本地html加载)。每次用户点击位于导航栏中的按钮,我都会从一个webview切换到另一个页面卷曲动画(卷曲和卷曲)。一切似乎工作正常,但有时应用程序冻结时,用户点击该按钮。在大多数情况下,应用程序冻结时,我repeteadly轻按按钮,直到应用程序死机,然后我暂停调试和我得到这个:UIWebthreadlock冻结应用程序

enter image description here

self.navigationItem.titleView.userInteractionEnabled = NO; //Disable button interaction until animation is finished 

if (self.isVisibleFrontView) 
    { 
    self.isVisibleFrontView = NO; 

    [UIView transitionWithView:self.view 
         duration:0.5 
         options:UIViewAnimationOptionTransitionCurlUp | UIViewAnimationOptionCurveEaseInOut 
        animations:^{ 
         [[[self.view subviews] objectAtIndex:0] removeFromSuperview]; 
         [self.view addSubview:self.patientViewReverse]; 

        } 
        completion:^(BOOL finished){ 
         self.navigationItem.titleView.userInteractionEnabled = YES; 
        }]; 
} 
else 
{ 

    self.isVisibleFrontView = YES; 

    [UIView transitionWithView:self.view 
         duration:0.5 
         options:UIViewAnimationOptionTransitionCurlDown | UIViewAnimationOptionCurveEaseInOut 
        animations:^{ 
         [[[self.view subviews] objectAtIndex:0] removeFromSuperview]; 
         [self.view addSubview:self.patientView]; 

        } 
        completion:^(BOOL finished){ 
          self.navigationItem.titleView.userInteractionEnabled = YES; 

        }]; 

} 
[self showNavigationBarButtons]; //change button image 
} 

我觉得Webview是获取锁时removeFromSuperview但在某些病例从不释放它,导致主线程冻结。你怎么看?在不冻结应用程序的情况下实现此目标的最佳方法是什么?

在此先感谢你们。

回答

0

最后我修复了它。

现在我所做的只是设置隐藏:是的webview我不想显示和setHidden:没有其他的webview在动画块,而不是每次删除和添加为子视图的webviews。这是更高效的,webview不使用webthreadlock。