2011-05-20 85 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]; 
}