【发布时间】:2013-12-19 19:58:39
【问题描述】:
我正在尝试通过单击单元格来填充 UITableViewController 中的 UITextFields。因此,我创建了一个 init 方法,例如:
- (id)initWithObjetoFormulario:(ObjetoFormularioGerenciador *)umObjeto
{
self = [super init];
if(self){
self.objetoFormulario = umObjeto;
}
return self;
}
在我的ViewDidLoad 中,我输入了if(self.objetoFormulario){ 行,然后将 UITextFields 链接到我的对象。我不认为在这一点上有什么问题。
所以,我的第二个 TableViewController 是一个 SearchDisplayController,它可以找到我需要的数据,并且在 didSelectRowAtIndexPath 我有:
ObjetoFormularioGerenciador *objeto = [[ObjetoFormularioGerenciador alloc] init];
[objeto RecebeArrayComDadosECriaObjetoFormularioGerenciador:_arrayComDados eEmail: [searchResults objectAtIndex:indexPath.row]];
GerenciarSeriesTableViewController *gerenciador = [[GerenciarSeriesTableViewController alloc] initWithObjetoFormulario:objeto];
[self.navigationController pushViewController:gerenciador animated:NO];
由于我的单元格中没有实际的对象,我调用了一个方法来根据单元格条目检索对象,这也可以正常工作,现在,当我单击单元格时它会打开一个空白的 TableView。它应该使用包含 UITextField 的静态单元格返回到我的 tableView 并填充它们。
当我使用这段代码时:
ObjetoFormularioGerenciador *objeto = [[ObjetoFormularioGerenciador alloc] init];
[objeto RecebeArrayComDadosECriaObjetoFormularioGerenciador:_arrayComDados eEmail:[searchResults objectAtIndex:indexPath.row]];
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
GerenciarSeriesTableViewController *gerenciador = [sb instantiateViewControllerWithIdentifier:@"GerenciarSeriesTableViewController"];
[self.navigationController pushViewController:gerenciador animated:NO];
它确实打开了我想要的 TableView,但它没有填充 UITextFields,因为我没有传递任何对象。
谢谢。
【问题讨论】:
-
RecebeArrayComDadosECriaObjetoFormularioGerenciador:eEmail有史以来最糟糕的方法名称。 -
谢谢 :) 这样更容易跟踪我在做什么。
标签: ios objective-c uitableview storyboard