将变量传递给 TabBar 中调用的视图
我在将变量传递给视图时遇到问题。
我有三个视图:
ListagemReceitas - 带 TableView 的视图
BlocoReceita - 带 TabBar 的视图
CapaReceita - 带要显示数据的视图
流程是这样的
- :单击 tableView 到视图 我将视图称为 ListagemReceitas BlocoReceita
- 视图 CapaReceita 链接到选项卡栏的项目 1,并且每当视图时都会显示BlocoReceita被调用,需要接收一个变量来定位要显示的信息;
当我在视图中单击 BlocoReceita tableView ListagemReceitas 来调用视图时,我使用以下代码直接转到视图 CapaReceita 变量:
Receita_Capa_iPhone detailViewController = * [[Receita_Capa_iPhone alloc] initWithNibName: @ "Receita_Capa_iPhone" bundle: nil];
NSDictionary * dict = [arrCanapes objectAtIndex: indexPath.row];
[detailViewController setCodigo: [dict objectForKey: @ "code"]];
仅当加载视图 CapaReceita (viewWillAppear) 时,数据检索为 null。
我尝试传递代码来查看 BlocoReceita,并通过 viewWillAppear 传递代码来查看 CapaReceita,但无济于事。
我直接在视图中点击view CapaReceita tableView ListagemReceitas进行了测试调用,然后就可以了。但是当我调用这个视图并且 BlocoReceita CapaReceita 自动加载视图时,数据就无效了。
有人能告诉我可能出了什么问题吗?如果你有什么具体的方法吗?
我用代码调用视图 BlocoReceita:
[self.navigationController presentModalViewController: receitaViewController animated: YES];
因为它有一个独立于 TabBar ListagemReceitas 视图的 TabBar,所以不使用“pushViewController”。
I have a problem in time to pass a variable to a view.
I have three views:
ListagemReceitas - View with TableView
BlocoReceita - View with TabBar
CapaReceita - View with data to be displayed
The flow is this:
- At the click of tableView to the view I call the view ListagemReceitas BlocoReceita
- The view CapaReceita which is linked to item 1 of the tabbar, and is displayed whenever the view BlocoReceita is called, needs to receive a variable to locate the information to be displayed;
When I call the view at the click of BlocoReceita tableView ListagemReceitas in view, I go directly to the view CapaReceita variable with the code below:
Receita_Capa_iPhone detailViewController = * [[Receita_Capa_iPhone alloc] initWithNibName: @ "Receita_Capa_iPhone" bundle: nil];
NSDictionary * dict = [arrCanapes objectAtIndex: indexPath.row];
[detailViewController setCodigo: [dict objectForKey: @ "code"]];
Only when the view is loaded CapaReceita (viewWillAppear), data is retrieved as null.
I've tried to pass the code to view BlocoReceita, and it viewWillAppear pass code to view CapaReceita, but to no avail.
I made a test call directly at the click of view CapaReceita tableView ListagemReceitas in view, and then it works. But when I call this view and BlocoReceita CapaReceita automatically loads the view, then the data is as void.
Could someone tell me what might be wrong? If you have any specific method for this?
I call the view BlocoReceita with the code:
[self.navigationController presentModalViewController: receitaViewController animated: YES];
because as it has a TabBar independent of the TabBar ListagemReceitas view, not given to do using "pushViewController."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在以下位置添加 NSLog 语句:
NSDictionary * dict = [arrCanapes objectAtIndex: indexPath.row];
NSLog(@"dict = %@",dict); // 添加这个
我打赌你会发现字典没有正确实例化。
Put an NSLog statement after the:
NSDictionary * dict = [arrCanapes objectAtIndex: indexPath.row];
NSLog(@"dict = %@",dict); // Add this
I bet you will find that the dictionary isn't getting instantiated properly.