我应该如何将一个字符串传递给在选中tableviewcell时被推入的视图控制器。 我应该在视图控制器中创建一个自定义的init方法吗?例如[[myvc alloc]initWithURL:...]
设置属性?例如[myvc setURL:...]
或myvc.url = ...
或者只是创建一个自定义的方法? [myvc setLoadingURL:...]
将字符串从tableviewcontroller传递给导航堆栈中的viewcontroller
0
A
回答
0
我们实际上已经完成了这两种方式(使用init和property)。我发现该属性是最好的方法,因为如果ViewController是由InterfaceBuilder创建的,则可能不会调用自定义init方法。随着财产,你总是被迫设置它,如果你想使用它。
只需$ 0.02,
-dan
0
任何这些解决方案都是可以接受的。我想如果你只是传递一个字符串,那么一个属性就足够了。我一直在为更复杂的对象保存init方法。这里有一个我最近的“高分”表格,当你挖一排,显示在堆栈上的轮廓图:
ProfileController *profileController = [[ProfileController alloc] initWithNibName:@"ProfileController" bundle:nil];
// pass the controller the player object
[profileController showProfile:player];
// show it by pusing it on the stack
[self pushViewController:profileController animated:YES];
[profileController release];
我可以创建另一个初始化像
ProfileController *profileController = [[ProfileController alloc] initWithPlayer:player];
代替。这看起来更优雅一些,但正如我所说,你的任何方法都可以。
相关问题
- 1. 在导航堆栈中的ViewController
- 2. 多次将相同的TableViewController导入导航堆栈
- 3. 在导航卸下的ViewController堆栈
- 4. 如何将字符串从一个tableViewController传递到使用导航的其他tableViewController
- 5. 如何将字符串从一个viewcontroller传递给另一个?
- 6. iPhone - 从孩子将数据传递到父在导航堆栈
- 7. 从导航堆栈
- 8. 加载UIView到导航堆栈不传递字符串到新视图
- 9. 如何在将数据推送到导航堆栈之前将数据传递给viewcontroller并加载它?
- 10. 将字符串传递给$
- 11. 将文本从UITextView传递到不同ViewController中的字符串
- 12. 将字符串从IronPython传递给Javascript
- 13. 将堆栈传递给方法
- 14. 将字符串从IHttpHandler传递给Javascript,然后传递给Silverlight
- 15. 从文本字段以字符串,并将它传递给以前的viewController
- 16. 将字符串值传递给viewcontroller,但获取EXC_BAD_ACCESS
- 17. 如何在导航堆栈中的viewcontroller中设置stringobject的值?
- 18. 反转从堆栈中的字符串
- 19. 从堆栈导航到CDB/WinDbg中的托管堆栈中的堆栈帧
- 20. 堆栈字符串
- 21. 将TableviewController B中的图标和名称传递给TableviewController A
- 22. 字符堆栈,字符串堆栈,整数堆栈,整数数组堆栈等
- 23. 委托/协议不起作用:将数组从TableViewController传递给父ViewController
- 24. 导航堆栈在iPhone中
- 25. 从AppDelegate将NSDictionary传递给ViewController
- 26. 将NSString从ViewController传递给NSObject
- 27. 从ViewController到TableViewController
- 28. Viewpilotlers从导航堆栈中缺失
- 29. 从导航堆栈中删除网页
- 30. 如何在复杂的导航堆栈之间传递变量