2011-05-20 49 views
2

地獄所有,應用程序崩潰[scrollView removeFromSuperview];

我是新來的iPhone和下面的問題掙扎。
當我刪除滾動視圖與下面的聲明我appli崩潰。

[scrollView removeFromSuperview]; 

我正在用以下行添加uiscrollview。

[self.view addSubview:scrollView]; 

這裏是日誌。

Thread 0 Crashed: 
0 libobjc.A.dylib     0x34a80466 objc_msgSend + 18 
1 UIKit       0x341aaaa8 -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 152 
2 UIKit       0x341aaace -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 190 
3 UIKit       0x341aaace -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 190 
4 UIKit       0x341c05a0 -[UIView(Hierarchy) removeFromSuperview] + 208 
5 UIKit       0x34249a76 -[UIScrollView removeFromSuperview] + 42 
6 KabushikiShimbun    0x000387b6 -[PDFPageScrollViewController ReGenerateScrollViewAsperNewData] (PDFPageScrollViewController.m:1451) 
7 KabushikiShimbun    0x00038aac -[PDFPageScrollViewController CheckPageUpdationWithDate:] (PDFPageScrollViewController.m:1441) 
8 KabushikiShimbun    0x0003c472 -[PDFPageScrollViewController requestFinished:] (PDFPageScrollViewController.m:792) 
9 CoreFoundation     0x35818bb8 -[NSObject(NSObject) performSelector:withObject:] + 16 
10 KabushikiShimbun    0x0000e9ba -[ASIHTTPRequest reportFinished] (ASIHTTPRequest.m:1945) 
11 CoreFoundation     0x35818bb8 -[NSObject(NSObject) performSelector:withObject:] + 16 
12 Foundation      0x3118178e __NSThreadPerformPerform + 262 
13 CoreFoundation     0x358307d6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6 
14 CoreFoundation     0x358025b0 __CFRunLoopDoSources0 + 376 
15 CoreFoundation     0x35801e54 __CFRunLoopRun + 224 
16 CoreFoundation     0x35801c80 CFRunLoopRunSpecific + 224 
17 CoreFoundation     0x35801b88 CFRunLoopRunInMode + 52 
18 GraphicsServices    0x320c84a4 GSEventRunModal + 108 
19 GraphicsServices    0x320c8550 GSEventRun + 56 
20 UIKit       0x341dc322 -[UIApplication _run] + 406 
21 UIKit       0x341d9e8c UIApplicationMain + 664 
22 KabushikiShimbun    0x00002da6 main (main.m:14) 
23 KabushikiShimbun    0x00002d70 start + 32 

任何想法?
謝謝。

+0

你能發表一些代碼嗎?它可能是一個無效的對象。 – 2011-05-20 05:19:58

+0

你能展示你的更多代碼嗎? – 2011-05-20 05:20:02

+0

您是否使用調試器進行了檢查?像使用scrollview firstresponder使用線路崩潰的地方?/ – 2011-05-20 05:21:23

回答

0

試試看看這個代碼。它已經過測試。

NSArray *subviews = [[NSArray alloc] initWithArray:self.view.subviews]; 
for(UIScrollView *subview in subviews) { 
    [subview removeFromSuperView]; 
} 
[subviews release]; 

,但要小心它會刪除所有ScrollViews出現在您的self.view

1

試試這個代碼

for(UIView *view in self.view.subviews) 

{ 
    if([view isMemberOfClass:[UIScrollView class]]) 
    { 
     [scrollview removeFromSuperView]; 
    } 
} 
1

檢查其是否具有來自上海華刪除前的上海華;

if([scrollView superview]!=nil){ 
    [scrollView removeFromSuperview]; 
}