怎么从一个View中跳转到另一个Controller

2025-04-24 07:09:51
推荐回答(1个)
回答1:

相当不推荐直接在View的代码里处理画面跳转,这些事情应该放在Controller里处理。
建议使用Delegate的方式,把Controller作为那个View的Delegate。回调了Delegate然后跳转画面。
可以参考UITableView的那种处理方式
步骤一:
#import "AppDelegate.h"

步骤二:

在需要跳转的地方:

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
UITabBarController *tabViewController = (UITabBarController *) appDelegate.window.rootViewController;
[tabViewController setSelectedIndex:2];