我想知道如果我可以製作一個基本的UITableView並靜態設置一切使用IB/Storyboarding在Xcode 4.2中,但只是我想顯示當前應用程序版本的單元格之一。 (我正在做一個關於視圖),我不想硬編碼的應用版本,因爲我知道我會忘記更新它的道路。有沒有辦法讓一個單元從dataSource中獲取數據?我試圖實現在IB/Storyboarding中創建的靜態UITableView使用動態內容?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
if (indexPath.section == 0 & indexPath.row == 0) {
cell.textLabel.text = [self appVersion];
}
return cell;
}
我已經試過所有細胞cellIdentifier設置爲@「細胞」以及剛剛把它放在我關心修飾細胞。
並且只針對該單元格返回應用程序版本,但會清除所有其他單元格的內容。
發佈`cellForRowAtIndexPath:`的整個實現。你要做的事情非常簡單,不應該像你描述的那樣影響所有單元格。 – MusiGenesis 2011-12-16 21:41:49