0

我遇到了某种崩溃,这是崩溃堆栈:

 WebCore 0x353c81b4 WebCore::PageCache::markPagesForFullStyleRecalc(WebCore::Page*) + 20
 WebKit 0x36a6a45f -[WebView(WebPrivate) _initWithFrame:frameName:groupName:usesDocumentViews:] + 139
 WebKit 0x36a6a3cd -[WebView initWithFrame:frameName:groupName:] + 53
 WebKit 0x36a6a393 -[WebView initWithFrame:] + 47
 UIKit 0x37251bfb -[UIWebDocumentView initWithWebView:frame:] + 287
 UIKit 0x372828d1 -[UIWebBrowserView initWithWebView:frame:] + 57
UIKit 0x37282891 -[UIWebDocumentView initWithFrame:] + 41
UIKit 0x37282809 -[UIWebBrowserView initWithFrame:] + 49
UIKit 0x37437d73 -[UIWebView _webViewCommonInitWithWebView:scalesPageToFit:shouldEnableReachability:] + 235
UIKit 0x374385a9 -[UIWebView initWithFrame:] + 81
SeMob 0x001c216d -[SeMobWebInternalView initWithFrame:] (SeMobWebInternalView.m:64)
SeMob 0x001e7761 -[SeMobWebReader prepareReaderInWebView:] (SeMobWebReader.m:102)
SeMob 0x000eeb0d -[SeMobWebView webViewDidFinishLoad:] (SeMobWebView.m:1475)
CoreFoundation 0x346979c4 __invoking___ + 68
CoreFoundation 0x345eefeb -[NSInvocation invoke] + 287
CoreFoundation 0x345eeb43 -[NSInvocation invokeWithTarget:] + 51
WebKit 0x36a6189b -[_WebSafeForwarder forwardInvocation:] + 375
CoreFoundation 0x3469661b ___forwarding___ + 627
CoreFoundation 0x345edf68 __forwarding_prep_0___ + 24
CoreFoundation 0x346979c4 __invoking___ + 68
CoreFoundation 0x345eefeb -[NSInvocation invoke] + 287
WebCore 0x354197eb _ZL11SendMessageP12NSInvocation + 27
WebCore 0x35456fa5 _ZL20HandleDelegateSourcePv + 81
CoreFoundation 0x34669683 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
CoreFoundation 0x34668ee9 __CFRunLoopDoSources0 + 213
CoreFoundation 0x34667cb7 __CFRunLoopRun + 647
CoreFoundation 0x345daebd CFRunLoopRunSpecific + 357
CoreFoundation 0x345dad49 CFRunLoopRunInMode + 105
GraphicsServices 0x353432eb GSEventRunModal + 75
UIKit 0x37220301 UIApplicationMain + 1121
SeMob 0x000d48a7 main (main.m:12)

和两段代码:

- (void)prepareReaderInWebView:(UIWebView *)webView
{ 
// ...omit some code here

    if ([readableContent length]) {
        self.innerWebView = [[[SeMobWebInternalView alloc] initWithFrame:webView.bounds] autorelease];
        innerWebView.scalesPageToFit = NO;
        innerWebView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        innerWebView.scrollView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        innerWebView.scrollView.scrollsToTop = YES;
        innerWebView.delegate = self;
        ...
    }


@interface SeMobWebInternalView : UIWebView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
    // Initialization code
    UIMenuItem *flag =
    [[UIMenuItem alloc] initWithTitle:@"search" action:@selector(search:)];
    ...
}

崩溃总是发生在 super 的 init 方法中。为什么总是崩溃?请帮帮我!

4

2 回答 2

0

苹果文档说 UIWebView 不应该被子类化:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006950-CH3-DontLinkElementID_2

检查子类化注释。

于 2013-06-26T08:47:05.843 回答
0

正如@cosmin 所说,您不打算继承 UIWebView,从您的代码来看,您似乎在尝试自定义外观。试试这个代码:

webView.backgroundColor = [UIColor clearColor]; // changes to clear colour
webView.opaque = NO;

for(UIView *innerView in [[[webView subviews] objectAtIndex:0] subviews]) { // Hide images that make shadow
     if ([innerView isKindOfClass:[UIImageView class]]) {
         innerView.hidden = YES;
     }
}
于 2013-06-26T10:13:57.933 回答