2011-06-07 23 views
0

我有2個UITableView的設置和信息搜索結果如下2的UITableView在同一UIView的問題

IBOutlet UITableView* Settings ; 
IBOutlet UITableView* SearchResult; 

@property (nonatomic , retain) IBOutlet UITableView* Settings ; 
@property (nonatomic , retain) IBOutlet UITableView* SearchResult; 

在tableview中委託和源I由表名

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 

    if (tableView == Settings) { 

     return 2; 

    } else { 

     return 0 ; 
    } 
} 

搜索它們之間diffrentiate第二張桌子永遠不會觸發事件,我的意思是設置表格工作得很好,但第二個從未觸發事件,即使我設置了其數據源,並刪除文件所有者

[self.SearchResult reloadData];永遠不會觸發 任何建議,以解決

問候

回答

1

不宜段在第二臺數爲1,而不是0的事件? 第二個表是不可見的,如果段數爲0 ..

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 

    if(tableView == Settings) 
    { 

     return 2; 
    } 
    return 1; // Called for second table 
} 
+0

時,將其更改爲1它給exec_bad_ccess – AMH 2011-06-07 10:28:02

+0

我猜的錯誤是別的地方在你的cellForRow。嘗試刪除第二個返回,看看你是否得到第二個表。 – visakh7 2011-06-07 10:59:08

1

你有沒有手動設置這兩個表的委託和數據源???如果沒有設置它...這可能有助於

0
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    NSInteger *returnValue = 0; 

    if ([tableView isEqual:Settings]{ 
     NSLog (@"Settings did called datasource methods"); 
     returnValue = 2; // number of sections in your table - if you have NSArray datasource use [datasource count] ; 

    } else if ([tableView isEqual:SearchResult"){ 
     NSLog (@"SearchTable did called datasource methods); 
     returnValue = 1; // or count of that datasource 
    } 
    return returnValue; 
} 

這可能有助於調試