cordova项目多个原生界面间过场动画配置

来源:互联网 发布:会计网络继续教育东奥 编辑:程序博客网 时间:2024/06/11 20:40
本人ios小白,最近做混生开发(cordova + ionic + angularjs),由于对ios机制完全不理解,只能遇见一个问题解决一个问题了。项目需要打开外部网页,但是某条的网址有判断,不允许外部html引用,所以只能硬着头皮写原生界面来通过webview展示了(原生界面产生的原因)。在网上看到要设置过场动画需要UINavigationController这么个东西,可是cordova生成的OC代码并没有(也可能是没有找到,说了我是小白),各种尝试后,终于实现了。

AppDelegate

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions{//    这里是原来cordova生成的代码吧,改了好久了,记不清楚了    //    self.viewController = [[MainViewController alloc] init];    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    self.window.backgroundColor = [UIColor whiteColor];    MainViewController *root = [[MainViewController alloc]init];    UINavigationController *nav =[[UINavigationControlleralloc]initWithRootViewController:root];//先将root添加在navigation上    [nav setNavigationBarHidden:YES];    [self.window setRootViewController:nav];//navigation加在window上    //  侧滑返回    nav.interactivePopGestureRecognizer.enabled = YES;    nav.interactivePopGestureRecognizer.delegate =(id)self;    [self.window makeKeyAndVisible];    return YES;}
上面应该就是构造了一个UINavigationController。在使用的时候,大概就是取到当前的根视图吧。
    UINavigationController *result = nil;    UIWindow * window = [[UIApplication sharedApplication] keyWindow];    if (window.windowLevel != UIWindowLevelNormal)    {        NSArray *windows = [[UIApplication sharedApplication] windows];        for(UIWindow * tmpWin in windows)        {            if (tmpWin.windowLevel == UIWindowLevelNormal)            {                window = tmpWin;                break;            }        }    }    UIView *frontView = [[window subviews] objectAtIndex:0];    id nextResponder = [frontView nextResponder];    if ([nextResponder isKindOfClass:[UIViewController class]])        result = nextResponder;    else        result = (UINavigationController*)window.rootViewController;    // 将要展示的页面push进去 即可    EvidenceDetailViewController *edv = [[EvidenceDetailViewController alloc]init];    [result pushViewController:edv animated:YES];
最开始是没有做侧滑返回的,今天需求提出来了,又和这块打交道了,就整理了下。侧滑返回参考文章:http://blog.sina.com.cn/s/blog_65c178a80102v0f4.html
0 0
原创粉丝点击