我有一个问题,我猜,简单的事情。 我有一个(它不是一个SplitViewController)ViewController与其中的一个TableView对象。 我希望当用户点击表格中的一行时,右侧的标签会相应更改。didSelectRowAtIndexPath来分配值
我的标签(与文本“诺姆都温霍”右边),我想改变
@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];
填充的TableView
- (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'方法? – Mischa