0
如何將表格單元格按鈕對齊而不是右對齊?下面是我用來創建UIButton的代碼。謝謝。我該如何左對齊UITableViewCell中的按鈕
cell.accessoryView = [self getButton: @"icon.png"];
...
- (UIButton*)getButton: (NSString*)icon {
UIImage *image = (true) ? [UIImage imageNamed:icon] : [UIImage imageNamed:icon];
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 addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside];
button.backgroundColor = [UIColor clearColor];
return button;
}
從我過去的經驗來看,最好的辦法是將你自己的表格視圖單元格或添加按鈕作爲子視圖,而不使用accessoryView。 – 2012-03-29 20:16:52