ifparentViewContoller 语句
我正在编写一个带有 UITableView 的程序,并在导航栏中添加按钮,该按钮会导致编辑页面。当您单击表中的某个项目时,将推送一个视图 (rView),其中包含与该项目相关的信息。该视图有一个编辑按钮,也可通往编辑页面。有没有一种方法可以让我在编辑页面上为完成按钮添加一个 if 语句,表示“如果parentViewController 是要转到rView 的UITableView,否则是popViewController?”我假设有一种方法可以做到这一点,但我不确定这样做的语法。谢谢
I'm writing a program with a UITableView with and add button in the Navigation Bar which leads to an edit page. When you click on an item in the table, a view (rView) is pushed with information pertaining to that item. This view has an edit button that also leads to the edit page. Is there a way that I could put an if statement for the done button on the edit page that says "if parentViewController is the UITableView to go to rView, else popViewController?" I would assume there is a way to do this, but I'm not sure of the syntax to do so. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
推到它上面,
但是有可能省略第 2 步,你直接去到编辑屏幕。
现在,当弹出最后一个控制器时,您希望能够始终转到“rViewController”,即使它不在堆栈上。
首先,parentViewController 不是堆栈上的前一个控制器,而是 UINavigationController 本身,因此它与当前问题无关。
执行此操作的方法是使用 NSArray 显式设置 UINavigationController 的 viewControllers 属性。我还没有尝试过这个,但这应该可行:
当用户按下“添加”按钮时,而不是仅仅按下编辑视图控制器,而是执行以下操作:(
顺便说一句,我建议不要使用“rView”之类的名称,除非也许对于非常短暂的局部变量,比如在循环中,使用描述性名称是 Cocoa 习惯用法的一部分,从长远来看会给你带来很大帮助。)
If I understand correctly you have a UINavigationController and push onto it
But there is a possibility that step 2 is omitted and you go directly to the edit screen.
Now when the last controller is popped, you want to be able to always go to a "rViewController", even if it's not on the stack.
First of all, the parentViewController is NOT the previous controller on the stack, but rather the UINavigationController itself, so it has nothing to do with the present problem.
The way to do this is by setting the UINavigationController's viewControllers property explicitly with an NSArray. I haven't tried this but this should work:
When a user presses the "add" button, instead of just pushing the edit view controller, do something like:
(By the way, I would suggest not using names like "rView" except maybe for very short-lived local variables, like in a loop. Using descriptive names is very much part of the Cocoa idiom and will help you a lot in the long run.)