MD7中的MDAudioPlayerTableViewCell崩溃

时间:2013-10-03 14:52:42

标签: uitableview custom-controls ios7

我必须在我的iOS应用中使用MDAudioPlayerTableViewCell自定义tableView单元格。

它在iOS5和iOS6中运行良好,但在iOS7中没有。

当我运行它时,会出现以下错误崩溃消息并崩溃。

2013-10-03 21:07:36.401 MyApp[656:60b] -[UITableViewCellScrollView drawContentView:]: unrecognized selector sent to instance 0x15f71390
2013-10-03 21:07:36.403 MyApp[656:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCellScrollView drawContentView:]: unrecognized selector sent to instance 0x15f71390'
*** First throw call stack:
(0x2f2e6f53 0x399516af 0x2f2ea8e7 0x2f2e91d3 0x2f238598 0xc4b5f 0x31ad8001 0x31710171 0x316f99f7 0x317d286d 0x316f92ab 0x316f8f53 0x316dcc5d 0x316dc8f5 0x316dc2ff 0x316dc10f 0x316d5e3d 0x2f2b21d5 0x2f2afb79 0x2f2afebb 0x2f21ace7 0x2f21aacb 0x33ee8283 0x31abca41 0xa3c79 0xa3c00)
libc++abi.dylib: terminating with uncaught exception of type NSException

以下是cellForRowAtIndexPath中的代码。

static NSString *CellIdentifier = @"Cell";

    MDAudioPlayerTableViewCell *cell = (MDAudioPlayerTableViewCell *)[tbl dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil)
    {
        cell = [[MDAudioPlayerTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

我如何为iOS7解决它?

2 个答案:

答案 0 :(得分:6)

假设您有一个扩展UIView的单元格视图

@interface CellView : UIView

- (void) drawRect:(CGRect)r;

@end

在您的实施中,您有类似这样的内容

@implementation CellView

- (void)drawRect:(CGRect)r {
    [(Cell *)superview drawContentView:r];
}

@end 

只需用

替换它
@implementation CellView

- (void)drawRect:(CGRect)r {
    UIView *superview = [self superview];
    if (![superview isKindOfClass:[UITableViewCell class]]) {
        superview = [superview superview];
    }
    [(Cell *)superview drawContentView:r];
}

@end 

干杯

答案 1 :(得分:0)

UITableViewCell Internal View Hierarchy Change in iOS7

- (void)drawRect:(CGRect)rect {
    [(CustomCell *)[[self superview] superview] drawContentView:rect];
}