English 中文(简体)
UI Webthreadlock 冻结应用程序
原标题:UIWebthreadlock freezes app

我在 wich 中看到两种不同的 uiwebview( 从本地 html 上载 ) 。 每次用户按下导航栏中的一个按钮, 我就会用一个网络视图转换成另一个页面卷曲动画( 向上弯曲, 向下弯曲 ) 。 似乎一切都很好, 但当用户按下按钮时, 程序有时会冻结。 在多数情况下, 当我按下按钮重写时, 程序会冻结, 直到应用程序冻结, 然后我暂停调试程序, 我得到这个消息 :

""https://i.sstatic.net/hDwB.png" alt="此处输入图像描述"/ >

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在移除“从审查”时正在获取锁,但在某些情况下从未释放它,导致主线冻结。你认为怎样?在不冻结应用程序的情况下实现这一点的最佳方法是什么?

感谢大家提前。

问题回答

终于修好了

现在,我所做的就是设置Hidden:YES 我不想显示和设置Hidden: 没有其它在动画块中的网络视图, 而不是每次删除和作为子视图添加 Webview。 这样效率更高, Webview没有使用 Webthreadlock 。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签