我有最後一個問題,是我殺了。 我正在玩一個使用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