2012-01-27 36 views
1

我MasterViewController.h如下:UITableView的相關方法沒有運行

@interface XYZMasterViewController : UITableViewController <NSFetchedResultsControllerDelegate, UIAlertViewDelegate> { 
    NSMutableArray *array; //unimportant 
    NSUInteger buttonIndex; //unimportant 
    BOOL waitForAction; //unimportant 
    NSString *titleEntered;//unimportant 
    NSString *duedateEntered; //unimportant 
} 

,並在我的(.M)文件我聲明的方法:

- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)actionforRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender 
{ 
    NSLog(@"canPerformAction Method entered"); 
    [self switchTitle:tableView indexPath:indexPath]; 
    return YES; 
} 

,但它不是在所有運行, NSLog從不打印出來。這就像它被忽略,只是繼續與應用程序的其餘部分。

謝謝4任何幫助!

+0

您需要將表視圖上的委託設置爲指向控制器實例。 – 2012-01-27 13:43:04

回答

1

那麼,你是否明確地從某處調用了你的函數,或者你是否爲它編寫了自定義的UITableViewDelegate?如果兩者都不存在,難怪它不會被調用。

我認爲你正在尋找的功能是

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

而且不要忘記設置你的類作爲表的委託,實施其他委託功能。

相關問題