Fir*_*ist 1 custom-controls uitableview 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
Run Code Online (Sandbox Code Playgroud)
这是代码cellForRowAtIndexPath.
static NSString *CellIdentifier = @"Cell";
MDAudioPlayerTableViewCell *cell = (MDAudioPlayerTableViewCell *)[tbl dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[MDAudioPlayerTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Run Code Online (Sandbox Code Playgroud)
我如何为iOS7解决它?
假设你有一个扩展UIView的cellview
@interface CellView : UIView
- (void) drawRect:(CGRect)r;
@end
Run Code Online (Sandbox Code Playgroud)
在您的实现中,您有类似这样的东西
@implementation CellView
- (void)drawRect:(CGRect)r {
[(Cell *)superview drawContentView:r];
}
@end
Run Code Online (Sandbox Code Playgroud)
只需替换它
@implementation CellView
- (void)drawRect:(CGRect)r {
UIView *superview = [self superview];
if (![superview isKindOfClass:[UITableViewCell class]]) {
superview = [superview superview];
}
[(Cell *)superview drawContentView:r];
}
@end
Run Code Online (Sandbox Code Playgroud)
干杯
瑞
| 归档时间: |
|
| 查看次数: |
322 次 |
| 最近记录: |