0
新的Xcode和我正在瀏覽一些蘋果的文件,它顯示了我如何設置文本和字幕。我對指南的問題是如何實施它們。拆分表查看數組到標籤和字幕
這是我的數組目前是如何:
- (void)viewDidLoad {
[super viewDidLoad];
//Initialize the array.
listOfItems = [[NSMutableArray alloc] init];
//Add items
[listOfItems addObject:@"Iceland"];
[listOfItems addObject:@"Greenland"];
[listOfItems addObject:@"Switzerland"];
[listOfItems addObject:@"Norway"];
[listOfItems addObject:@"New Zealand"];
[listOfItems addObject:@"Greece"];
[listOfItems addObject:@"Rome"];
[listOfItems addObject:@"Ireland"];
}
,這是它如何返回數據:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier];
}
// Set up the cell...
NSString *cellValue = [listOfItems objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
}
這只是標題,雖然,我想提出一個字幕。 我會插入什麼代碼來實現字幕?
由於提前
我沒有看到差異 – kezi 2012-08-13 21:38:46
如何設置單元格的樣式? – kezi 2012-08-13 21:46:44
在應用程序的故事板中設置桌子原型單元格上的樣式。 (突出顯示單元格,轉到右側列中的屬性檢查器,然後查找「樣式」)。或者在代碼中,您可以在創建單元時使用初始化方法'initWithStyle:reuseIdentifier:'。 – jonkroll 2012-08-13 21:50:56