【发布时间】:2012-03-20 23:56:12
【问题描述】:
我有带有自定义表格行的 UITableView。我需要的是有可能重新排序行。所以在 ViewDidLoad 我添加:
- (void)viewDidLoad {
[super viewDidLoad];
[self.myTableView setEditing: YES animated: YES];
}
还添加下一个方法:
- (BOOL)tableView:(UITableView *)tableView
canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView
editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleNone;
}
- (BOOL)tableView:(UITableView *)tableView
shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
- (BOOL)tableView:(UITableView *)tableView
canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
我还为我的自定义表格行设置了背景颜色:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *customTableRow = @"customTableRow";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
customTableRow];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"customTableRow"
owner:self options:nil];
if (nib.count > 0) {
cell = self.customTableRow;
}
}
cell.contentView.backgroundColor = [UIColor colorWithRed:(228.0f/255.0f)
green:237.0f/255.0f blue:244.0f/255.0f alpha:1.0];
return cell;
}
然后我运行我的应用程序,我看到了一个意想不到的视图:
所以我有两个问题:
1.那为什么会这样?重新排序按钮不透明??
2.如何将该按钮更改为我的图像??
【问题讨论】:
标签: iphone uitableview