代码之家  ›  专栏  ›  技术社区  ›  SaltyNuts

UIScrollView/UITableView在调整帧大小时崩溃

  •  2
  • SaltyNuts  · 技术社区  · 15 年前

    所以我可以随时调整滚动视图的大小,如下所示:

    NSInteger offset = -50;
    if (self.bannerIsVisible) offset = 50;
    CGRect frame = scrollView.frame;
    frame.size.height += offset;
    scrollView.contentSize = CGSizeMake(frame.size.width * pages, frame.size.height);
    scrollView.frame = frame;
    

    2010-07-27 10:25:31.779 MyAPP[8026:207] -[__NSArrayM tableView:cellForRowAtIndexPath:]: unrecognized selector sent to instance 0x736eb20
    2010-07-27 10:25:31.781 MyAPP[8026:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM tableView:cellForRowAtIndexPath:]: unrecognized selector sent to instance 0x736eb20'
    *** Call stack at first throw:
    (
        0   CoreFoundation                 0x026cb919 __exceptionPreprocess + 185
        1   libobjc.A.dylib                0x028195de objc_exception_throw + 47
        2   CoreFoundation                 0x026cd42b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
        3   CoreFoundation                 0x0263d116 ___forwarding___ + 966
        4   CoreFoundation                 0x0263ccd2 _CF_forwarding_prep_0 + 50
        5   UIKit                          0x003a3a3f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 619
        6   UIKit                          0x00399ad2 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
        7   UIKit                          0x003ae40c -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
        8   UIKit                          0x003a60d7 -[UITableView(_UITableViewPrivate) _setNeedsVisibleCellsUpdate:withFrames:] + 372
        9   UIKit                          0x003a37cd -[UITableView setFrame:] + 266
        10  UIKit                          0x00367ae8 -[UIView(Geometry) resizeWithOldSuperviewSize:] + 385
        11  UIKit                          0x0036ba2b -[UIView(Geometry) resizeSubviewsWithOldSize:] + 273
        12  UIKit                          0x00367f79 -[UIView(Geometry) setFrame:] + 497
        13  UIKit                          0x0038085f -[UIScrollView setFrame:] + 617
        14  MyAPP                          0x0000a678 -[MyViewController toggleBanner] + 893
    

    1 回复  |  直到 15 年前
        1
  •  2
  •   Jason Foreman    15 年前

    这看起来很像是表视图的数据源对象被释放了,因此委托方法被发送到另一个对象。这是一个内存管理问题,因此您可以尝试使用Zombies工具运行应用程序,看看它是否发现了这个问题。