我已经创建了一个框架工作,其中包含3个视图控制器。
用户应用程序视图名称
userViewController
|
clickherebtn to load Framework
框架评估:
sdkview1controller
sdkview2controller
sdkview3controller
应用程序对框架流的调用
在点击hit时,我加载了类似于这个辅导方式的框架
从sdkview1controller视图返回
[self dismissViewControllerAnimated:NO completion:nil];
但是如果我的调用视图是
userViewController -> sdkview3controller 1控制器->sdkview2控制器->sdkview3controller
现在,我想跳回userViewController,在sdkview3controller中按回按钮
注意: userViewController的名称不是固定的,所以我的问题是如何回到app视图,直接跳过框架中所有加载的视图?
发布于 2016-02-01 06:58:39
UIViewController *vc = self.presentingViewController;
NSArray* classes = @[[sdkview1controller class],
[sdkview2controller class],
[sdkview3controller class]];
while (vc.presentingViewController) {
vc = vc.presentingViewController;
if(! [classes containsObject:[vc class]])
break;
}
[vc dismissViewControllerAnimated:YES completion:NULL];
如果您使用presentViewController:
添加了所有视图控制器(我假设您添加了),这将消除所有的链接,并使用户返回到userViewController
发布于 2016-02-01 07:40:25
在您的应用程序中添加一个导航控制器作为rootviewcontroller,并按以下方式推送框架视图控制器:
Common *com_obj = [Common sharedInstance];
com_obj.viewc =self; ////////assiging the app viewcontroller which will be used to pop
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"CommonBundle" ofType:@"bundle"];
NSBundle *mobtestBundle = [NSBundle bundleWithPath:bundlePath];
UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:mobtestBundle];
ViewController1 *viewc1=[story instantiateViewControllerWithIdentifier:@"ViewController1"];
[self.navigationController pushViewController:viewc1 animated:YES];
sdk中的
在object类中,将属性添加为id viewc。
/////in sdkViewcontroller1 push as
ViewController2 *viewc1=[self.storyboard instantiateViewControllerWithIdentifier:@"ViewController2"];
[self.navigationController pushViewController:viewc1 animated:YES];
在后面的sdkViewcontroller2
Common *common = [Common sharedInstance];
[self.navigationController popToViewController:common.viewc animated:YES];
https://stackoverflow.com/questions/35124568
复制相似问题