我正在探索有关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;
}