从SDK返回App

时间:2016-02-01 06:54:52

标签: ios objective-c xcode frameworks

我创建了一个框架,里面有3个视图控制器

用户APP视图名称

userViewController
      |
      clickherebtn      to load Framework

框架appviews:

sdkview1controller
sdkview2controller
sdkview3controller

从App调用框架流程

on hit clickherebtn我加载了像tutorial way

这样的框架

从sdkview1controller视图返回,只需使用

    [self dismissViewControllerAnimated:NO completion:nil];

但如果我的主叫视图如何

userViewController - > sdkview1controller-> sdkview2controller-> sdkview3controller

现在我想在sdkview3controller中点击后退按钮跳回到userViewController

注意:userViewController的名称不固定,所以我的问题是 如何返回应用程序视图,直接跳过我框架中所有加载的视图?

2 个答案:

答案 0 :(得分:1)

<div class="codeWriteOn">
  <ul class="MonokaiBright">
    <li>
      <span>&#x3c;</span><span class="red">ul</span>
      <span class="green">class</span>&#61;<span class="yellow">&#8220;markup&#8221;</span><span>&#x3e;</span>
    </li>
    <li class="project1">
      &nbsp;&nbsp;<span>&#x3c;</span><span class="red">li</span>
      <span class="green">class</span>&#61;<span class="yellow">&#8220;project1&#8221;</span><span>&#x3e;</span>
      <!-- ">" --><span>Project-1&#x3c;</span><span class="red">/li</span><span>&#x3e;</span>
    </li>
    <li class="project2">
      &nbsp;&nbsp;<span>&#x3c;</span><span class="red">li</span>
      <span class="green">class</span>&#61;<span class="yellow">&#8220;project2&#8221;</span><span>&#x3e;</span>
      <!-- ">" --><span>Project-2&#x3c;</span><span class="red">/li</span><span>&#x3e;</span>
    </li>
    <li class="project3">
      &nbsp;&nbsp;<span>&#x3c;</span><span class="red">li</span>
      <span class="green">class</span>&#61;<span class="yellow">&#8220;project3&#8221;</span><span>&#x3e;</span>
      <!-- ">" --><span>Project-3&#x3c;</span><span class="red">/li</span><span>&#x3e;</span>
    </li>
    <li class="project4">
      &nbsp;&nbsp;<span>&#x3c;</span><span class="red">li</span>
      <span class="green">class</span>&#61;<span class="yellow">&#8220;project4&#8221;</span><span>&#x3e;</span>
      <!-- ">" --><span>Project-4&#x3c;</span><span class="red">/li</span><span>&#x3e;</span>
    </li>
    <li>
      &#x3c;</span><span class="red">/ul</span><span>&#x3e;</span>	
    </li>
  </ul>
</div>

如果您使用//Start initial task Task initTask = Xyz.Start(); //Continue initial task with something Task continueTask = initTask.ContinueWith((obj)=> { /*work work*/ }); //Wait for the initial task to finish (not the continue) initTask.Wait(); //Wait for the continue task to finish continueTask.Wait(); 添加了所有视图控制器(我假设您这样做了),这将解除所有链并让用户返回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];

答案 1 :(得分:1)

在您的应用中 添加导航控制器作为rootviewcontroller并将框架viewcontroller推送为:

 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中

在您的对象类中添加一个属性作为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];