这是我需要做的事情:
将66px x 66px图像加载到MainViewController表中的表格单元格中.每个TableCell都有一个独特的图像.
但是怎么样?我们会用cell.image
吗?
cell.image = [UIImage imageNamed:@"image.png"];
Run Code Online (Sandbox Code Playgroud)
如果是的话,在哪里?是否需要if/else语句?
要加载每个单元格的标签,MainViewController使用NSDictionary和NSLocalizedString,如下所示:
//cell one
menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
NSLocalizedString(@"PageOneTitle", @""), kTitleKey,
NSLocalizedString(@"PageOneExplain", @""), kExplainKey, nil]];
//cell two
menuList addObject:[NSDictionary dictionaryWithObjectsAndKeys:
NSLocalizedString(@"PageOneTitle", @""), kTitleKey,
NSLocalizedString(@"PageOneExplain", @""), kExplainKey, nil]];
Run Code Online (Sandbox Code Playgroud)
...
// this is where MainViewController loads the cell content
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MyCustomCell *cell = (MyCustomCell*)[tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
if (cell == nil)
{
cell = [[[MyCustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:kCellIdentifier] autorelease];
}
Run Code Online (Sandbox Code Playgroud)
...
// MyCustomCell.m adds the subviews
- (id)initWithFrame:(CGRect)aRect …
Run Code Online (Sandbox Code Playgroud)