应用程序在 [scrollView removeFromSuperview] 上崩溃;

发布于 2024-11-08 13:52:46 字数 2586 浏览 0 评论 0原文

哎呀,

我是 iPhone 新手,正在努力解决以下问题。
当我使用以下语句删除滚动视图时,我的应用程序崩溃了。

[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

有什么想法吗?
谢谢。

Hell All,

I am new to iPhone and struggling with following problem.
When i remove scroll view with following statement my appli crashes.

[scrollView removeFromSuperview];

I am adding uiscrollview with following line.

[self.view addSubview:scrollView];

Hereis the log.

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

Any Idea ?
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

叫嚣ゝ 2024-11-15 13:52:46

从superview中移除之前检查它是否有superview;

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

Check whether it has a superview before removing from superview;

if([scrollView superview]!=nil){
    [scrollView removeFromSuperview];
}
沐歌 2024-11-15 13:52:46

试试这个代码

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

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

Try this code

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

{
    if([view isMemberOfClass:[UIScrollView class]])
    {
        [scrollview removeFromSuperView];
    }
}
感性不性感 2024-11-15 13:52:46

试试这个代码。已经测试过了。

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

但要小心,它会删除 self.view 中存在的所有 ScrollViews

Try this code. It's tested.

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

but be carefull it removes all ScrollViews present in your self.view

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文