我想为我的应用程序中的所有 UITableViewCell 附件视图设置自定义图像。我试过使用这段代码:
[[UITableViewCell appearance] setAccessoryView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"table-arrow.png"]]];
但它不起作用。
任何想法?
我想为我的应用程序中的所有 UITableViewCell 附件视图设置自定义图像。我试过使用这段代码:
[[UITableViewCell appearance] setAccessoryView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"table-arrow.png"]]];
但它不起作用。
任何想法?
尝试在 UITableViewCell 类别中创建自定义外观选择器。这是一个示例实现:
。H:
- (void)setAccessoryViewImage:(UIImage *)image UI_APPEARANCE_SELECTOR;
米:
- (void)setAccessoryViewImage:(UIImage *)image {
self.accessoryView = [[UIImageView alloc] initWithImage:image];
}
而且您可以使用代理对象配置所有单元格:
[[UITableViewCell appearance] setAccessoryViewImage:[UIImage imageNamed:@"table-arrow.png"]];
// 尝试这个
cell.accessoryType = UITableViewCellAccessoryNone;
UIImageView *imgArrow = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 10, 15)] ;
imgArrow.image = [UIImage imageNamed:@"table-arrow.png"];
cell.accessoryView = imgArrow;
[imgArrow release];
imgArrow = nil;