所以我想在一個視圖中做兩個tableviews,我遇到了一些麻煩。 我已經閱讀了一些關於如何做的反應,但他們並不完全幫助我。在一個控制器中的兩個Tableviews
在我.h文件中我做了兩個網點爲兩種觀點稱他們在我的M檔myFirstViewText
和mySecondViewTex
所以對 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
我希望能夠在各個不同的打印出單獨的值控制器,我不太確定,因爲你只返回1個單元格?
到目前爲止我做這個
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Rx";
static NSString *CellIdentifier2 = @"allergies";
UITableViewCell *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:CellIdentifier];
UITableViewCell *cell2 = [tableView dequeueReusableHeaderFooterViewWithIdentifier:CellIdentifier2];
if(!cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (!cell2) {
cell2 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
}
if (tableView == self.myFirstTextView) {
cell.textLabel.text = @"HI JAZZY";//[RxDict objectAtIndex:indexPath.row];
}
if (tableView == self.mySecondTextView) {
cell.textLabel.text = @"BYE JAZZY";//[RxDict objectAtIndex:indexPath.row];
}
tableView = self.mySecondTextView;
cell2.textLabel.text = @"I love Jazzy :D";
return cell2;
這將打印「我愛爵士」在我第一次TableView中沒有東西印在了第二個。爲什麼會發生這種情況,我該如何解決? 感謝:D
爲什麼這個問題被低估? –