是否有可能改变tableviewcell中的uitableviewellaccess图像?改变uitableviewcellaccessory图像
2
A
回答
1
YES,在 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
方法使用此代码
UIImage *image = [UIImage imageNamed:@"yourImage.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height);
button.frame = frame;
[button setBackgroundImage:image forState:UIControlStateNormal];
button.backgroundColor = [UIColor clearColor];
cell.accessoryView = button;
2
当然可以。只需更换整个accessoryView的
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
// setup cell
UIImageView *aView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]] autorelease];
cell.accessoryView = aView;
return cell;
}
编辑:如果你想使用你的配件像disclosureButton有必要多一点点。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
// setup cell
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 44, 44);
[button setImage:[UIImage imageNamed:@"SettingsIcon.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(accessoryButton:withEvent:) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = button;
return cell;
}
- (void)accessoryButton:(UIControl*)button withEvent:(UIEvent *)event {
UITableView *tv = (UITableView*)[[button superview] superview];
UITableViewCell *cell = (UITableViewCell*)[button superview];
NSIndexPath *ip = [tv indexPathForCell:cell];
[tv.delegate tableView:tv accessoryButtonTappedForRowWithIndexPath:ip];
}
相关问题
- 1. InAppPurchase后更改UITableViewCellAccessory。可能?
- 2. 改变图像
- 3. JQuery改变图像
- 4. 改变图像到另一个图像
- 5. UITableViewCellAccessory检查
- 6. 禁用UITableViewCellAccessory
- 7. 改变图像不工作
- 8. 用jquery改变图像
- 9. QML改变图像大小
- 10. Javascript动态改变图像
- 11. Imageresizer水印 - 改变图像
- 12. 角背景图像改变
- 13. 的Javascript改变图像源
- 14. 改变背景图像jquery
- 15. jQuery改变图像位置
- 16. 的ImageButton不改变图像
- 17. 图像按钮不改变
- 18. 改变图像src在ie
- 19. jQuery .hover()不改变图像
- 20. 改变图像使用jQuery
- 21. 如何改变clipPath图像
- 22. UIButton不会改变图像
- 23. KineticJs改变图像对象
- 24. 改变图像的迅速
- 25. UITableViewCellAccessory多个部分
- 26. 动画移除UITableViewCellAccessory
- 27. Facebook,如何改变像按钮图像?
- 28. 当我按下图像,图像改变为其他图像
- 29. 改变方向变化的图像
- 30. WPF图像划像以改变iOS中的图像