2011-03-18 111 views
0

表視圖包含在常規視圖中。
正如預期的那樣,錄製「編輯」按鈕(在該表格視圖中)爲每一行顯示「帶有減號的紅點」(即,方法'setEditing'執行OK)。
但是,單擊這樣的紅點不會顯示相應的「刪除」按鈕('commitEditingStyle'不會執行)。
任何想法可能是錯誤的(請參閱下面的相關代碼)?編輯UITableView時,單擊紅點不能顯示'刪除'按鈕

//---- RootViewController.h ---- 
@interface RootViewController : UIViewController <NSFetchedResultsControllerDelegate> { //used to be a 'UITableViewController'. Changed to UIViewController and rewired so I could add an iAd banner and the tableView to it. Before that change, issue was not present (commitEditingStyle below used to work). 
... 
} 
@property (nonatomic, retain) IBOutlet UITableView *tableView; 

//----- RootViewController.m ---- 
- (void)viewDidLoad { 
    self.navigationItem.leftBarButtonItem = self.editButtonItem; 
    ... 
} 
- (void) setEditing:(BOOL)editing animated:(BOOL)animated { //Added so clicking 'Edit' displays red dots that rotate on tap (as expected). 
    [super setEditing:editing animated:animated];   
    [self.tableView setEditing:editing animated:animated]; 
    if (editing) {           
     NSLog(@"RootViewController setEditing");    //Executes OK. 
    } 
} 
- (void)tableView:(UITableView *)tableView     //Clicking a red dot no longer executes this method (so, does not display 'Delete' red button). 
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath {   

    NSLog(@"RootViewController commitEditingStyle");   //Does NOT execute. 
    ... 
} 
+0

有什麼代碼,使你的表格單元格看起來像?他們如何擺放? – occulus 2011-03-18 17:04:33

+0

連接和單元格:http://web.me.com/gguglielmo/Q/Q1.html – sambaMan 2011-03-18 17:53:36

+0

你有沒有想過這裏發生了什麼? – Rohan 2013-06-14 18:41:46

回答

0

仔細檢查你的有線起來,你都表的UITableViewDelegateUITableViewDataSource正確地編寫了新的UIViewController。

+0

連接和單元格佈局(位於web.me.com/gguglielmo/Q/Q1.html)顯示文件所有者的數據源和代理的插座已連接到表視圖。表單元格很簡單(並且沒有改變)。 – sambaMan 2011-03-18 18:05:50

0

確保cell.editingAccessoryView設爲零在:

-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { 
cell.editingAccessoryView = nil; 
} 
0

你沒有實現的tableView協議在您的.H ..你的類接口應該是這樣的

@interface RootViewController : UIViewController <NSFetchedResultsControllerDelegate, UITableViewDelegate,UITableViewDataSource> 
相關問題