【发布时间】:2014-01-20 15:32:04
【问题描述】:
我有两个通过 segue 连接的 ViewController,第一个是 Sub View,第二个是 Sub Tabela 我想将该表中选定行的值从我的第一个视图控制器传递到我的第二个视图控制器,以便我可以定义他的标题。 这是代码。
SubView.m(我的第一个 ViewController)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// _vinhoArray is the array that I populate the TableView
NSString *selectedRow = [_vinhoArray objectAtIndex:indexPath.row];
// Sub Tabela is the name of Second View
SubTabela *subTabela = [[SubTabela alloc] init];
// tituloTabela is a NSString in my Second View
subTabela.tituloTabela = linhaSelecionada;
// Here i get the Right value
NSLog(@"value %@", subTabela.tituloTabela);
}
SubTabela.h(我的第二个 ViewController)
@property (nonatomic, strong) NSString *tituloTabela;
SubTabela.m
@synthesize tituloTabela;
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = tituloTabela;
// Here i get the a Null value
NSLog(@"value %@", tituloTabela);
}
请帮忙!
【问题讨论】:
-
打开屏幕的代码在哪里?它非常重要,因为我认为我看到了您的错误
-
屏幕正在打开。对不起,如果我不明白,我是开发中的新手。
-
是的,我没有你使用 segue,但你还没有将调用 segue 的代码添加到你的问题中
-
@SimonMcLoughlin 那么我何时以及如何调用此方法?
标签: ios objective-c didselectrowatindexpath