我有一個問題,我猜,簡單的事情。 我有一個(它不是一個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