我正在探索几个关于 splitView 的 ios 示例,但所有示例都包含主菜单中的文本以供选择。我喜欢替换图像的文本,以便获得自定义按钮列表...有人可以帮助我吗?
。H
@property (nonatomic, retain) NSArray *siteNames;
@property (nonatomic, retain) NSArray *siteAddresses;
.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
siteNames = [[NSArray alloc] initWithObjects:
@"Yahoo",
@"Google",
@"Apple",
nil];
siteAddresses = [[NSArray alloc] initWithObjects:
@"http://www.yahoo.com",
@"http:/www.google.com",
@"http://www.apple.com",
nil];
[self.tableView selectRowAtIndexPath:
[NSIndexPath indexPathForRow:0 inSection:0]
animated:NO
scrollPosition:UITableViewScrollPositionMiddle];
}
编辑
好的,我确实知道如何将图像放入单元格中。我不知道如何从数组中执行此操作,请在下面查看我调整后的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
siteNames = [[NSArray alloc] initWithObjects:
//@"Yahoo",
//@"Google",
//@"Apple",
@"Yahoo.png",
@"Google.png",
@"Apple.png",
nil];
...
}
- (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];
}
//cell.textLabel.text = [siteNames objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:@" *** the right image ***"];
return cell;
}