1

我必须在我的 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 的问题?

4

2 回答 2

6

假设你有一个扩展 UIView 的 cellview

@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 

干杯

于 2013-10-13T17:02:22.873 回答
0

iOS7 中的 UITableViewCell 内部视图层次结构变化

- (void)drawRect:(CGRect)rect {
    [(CustomCell *)[[self superview] superview] drawContentView:rect];
}
于 2013-12-13T18:17:01.480 回答