我有最后一个问题,是我杀了。 我正在玩一个使用tableView:accessoryTypeForRowWithIndexPath
方法的旧项目,其中我试图在没有它的情况下重写应用程序。iphone(objective-c)附件修改错误
我删除了tableView:accessoryTypeForRowWithIndexPath
方法,但我的心不是解决方案的工作,只是还没有。
的问题是,现在当我按我的DetailViewController查看“编辑”按钮,在“编辑”附件类型不显示。
下面是我实际的代码,我已经还包括project file对于这一点,因为我绝望了一个可行的解决方案。
我的问题是,我有什么代码更改,让附件改变,并没有其他影响。 (我知道RootViewController的作品,但我怎么能得到DetailViewController表做?)
问候,@norskben
项目文件下载:Get it here.
setEditing
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
[self.navigationItem setHidesBackButton:editing animated:animated];
[tableView reloadData];
}
cellForRowAtIndexPath
- (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.editingAccessoryType = UITableViewCellAccessoryCheckmark;
}
switch(indexPath.section) {
case 0:
cell.textLabel.text = coffeeObj.coffeeName;
break;
case 1:
cell.textLabel.text = [NSString stringWithFormat:@"%@", coffeeObj.price];
break;
}
return cell;
}
项目文件下载:Get it here.
奇怪的是,你在正确的方向小刺固定的这一切。我是比较样本,发现我的DetailViewController是一个UIViewController而不是UITableViewController。 (接口生成器我链接视图与tableview,(从初始视图))。我在代码和界面构建器中进行了更改,然后配件开始工作!接下来我做的是添加一些代码来删除没有行删除的红色侧图标,最后一点是拼图的添加self.tableView.allowsSelectionDuringEditing = YES; //在viewDidLoad中取消添加。非常感谢。 – oberbaum 2010-01-30 23:06:34