【发布时间】:2014-02-24 15:48:09
【问题描述】:
我在一个简单的事情上遇到了问题。 我有一个(它不是 SplitViewController)ViewController,里面有一个 TableView 对象。 我希望当用户单击表格中的一行时,我右侧的标签会相应更改。
我想要更改的标签(右侧带有“Nome do Vinho”文字)
@property (weak, nonatomic) IBOutlet UILabel *rotuloDetalhesLabel;
我用这段代码填充 TableView。 我在 viewDidLoad 方法上创建对象并放入一个名为“vinhos”的 NSArray。
// Create object
Vinho *vinho1 = [Vinho new];
vinho1.rotulo = @"Adega de Borda Premium";
Vinho *vinho2 = [Vinho new];
vinho2.rotulo = @"Adega de Borda Premium 2";
// Populate the NSArray with the objects that I create before
vinhos = [NSArray arrayWithObjects: vinho1, vinho2, nil];
填充表格视图
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Configura a Cell
static NSString *CellIdentifier = @"TableCell";
TableCell *cell = (TableCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[TableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Vinho *vinho = [vinhos objectAtIndex:indexPath.row];
// rotuloLabel is the Label of the row
cell.rotuloLabel.text = vinho.rotulo;
return cell;
}
我猜它是在 didSelectRowAtIndexPath 方法上制作的,但我不知道如何。 如果我忘记发布重要的内容,请告诉我。
【问题讨论】:
-
能否请您发布您的
-didSelectRowAtIndexPath方法?
标签: objective-c ipad uitableview didselectrowatindexpath