sir*_*333 7 iphone uitableview uiimageview uiimage
我已经完成了一百万个UITables - 有字幕,图像,背景,颜色,文字样式 - 你可以说出来.突然间,我正在撞到这张桌子上,特别是在要求拍摄细胞图像的线上.这是代码:
// Configure the cell:
cell.textLabel.font = [UIFont fontWithName:@"Franklin Gothic Book" size:18];
cell.textLabel.text = [leadershipMenu objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [leadershipSubtitlesMenu objectAtIndex:indexPath.row];
// And here's the statement that causes the crash:
cell.imageView.image = [leadershipPhotosMenu objectAtIndex:indexPath.row];
Run Code Online (Sandbox Code Playgroud)
现在,我得到的错误是这样的:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSCFConstantString _isResizable]: unrecognized selector sent to instance 0xcacbc'
Run Code Online (Sandbox Code Playgroud)
我确定导致崩溃的声明是
cell.imageView.image = ...
Run Code Online (Sandbox Code Playgroud)
因为我一评论它一切正常.
我一生都没见过
-[__NSCFConstantString _isResizable]:
Run Code Online (Sandbox Code Playgroud)
错误.我用谷歌搜索了它,但发现它很少.
非常特别.
有人在那里有任何线索吗?
jan*_*del 12
正如您的评论中所述.保存图像的方式是导致问题的原因.
试试这个..
leadershipPhotosMenu = [[NSMutableArray alloc] initWithObjects:[UIImage imageNamed:@"JohnQ.jpg"], [UIImage imageNamed:@"BillZ.png"], nil];
Run Code Online (Sandbox Code Playgroud)
上面的代码会将图像存储在mutableArray中,这样可行,但我建议不要将图像存储在数组中.
您还可以解决您的问题,而无需像上面的代码那样将图像存储在数组中:
cell.imageView.image = [UIImage imageNamed:(NSString*)[leadershipPhotosMenu objectAtIndex:indexPath.row]];
Run Code Online (Sandbox Code Playgroud)
此错误消息表示您的对象内部leadershipPhotosMenu不是图像,而是字符串
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSCFConstantString _isResizable]: unrecognized selector sent to instance 0xcacbc'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3732 次 |
| 最近记录: |