zoukankan      html  css  js  c++  java
  • UINavigation Controller

    UINavigationController iPhone导航控制器/导航栏 是在iPhone程序中广为使用的用户数据互动方式。

    这是一个简单的导航栏截图,我们可以设置其内置UIView的title,而导航栏会显示出这个title。而不是设置导航栏的title。我们也可以设置其左侧,或者右侧的按钮或者自定义视图对象。我们下面来一步一步的看看导航栏的使用:
    创建并使用一个UINavigationController

    UINavigationController *aNav = [[UINavigationController alloc] init];

    然后添加一个视图进去,否则导航栏也没有意义的

    UIViewController *aView = [[UIView alloc] initWithNibName: (*xib文件名*)];
    [aNav pushViewController:aView animated:NO];
    //导航栏的第一个视图不要动画化

    设置导航栏的左右按钮:
    我说过,设置导航栏的按钮并不是去设置导航栏本身,而是当时被导航的视图控制器,比如我们对aView作设置。
    设置其标题:

    aView.title = @"标题";
     

    UIBarButtonItem *callModalViewButton = [[UIBarButtonItem alloc]
    initWithTitle:@"Button"
    style:UIBarButtonItemStyleBordered
    target:self
    action:@selector(callModalList)];
    self.navigationItem.leftBarButtonItem = callModalViewButton;
    [callModalViewButton release]; //由于本地视图会retain它,所以我们可以release了

    可以看到,还是很简单的嘛。
    其他常用方法和属性:

    本地视图.navigationItem.leftBarButtonItem //左边栏项目
    本地视图.navigationItem.rightBarButtonItem //右边栏项目
    本地视图.navigationItem.backBarButtonItem //后退栏项目

    本地视图.navigationItem.hidesBackButton //隐藏后退按钮(YES or NO)

    Navigation Controller 是最重要的iPhone组建之一了,以下是一些“关键方法”

    pushViewController:viewController animated:BOOL

    (加载视图控制器)
    – 添加指定的视图控制器并予以显示,后接:是否动画显示

    popViewControllerAnimated:BOOL

    (弹出当前视图控制器)
    – 弹出并向左显示前一个视图

    popToViewController:viewController animated:BOOL

    (弹出到指定视图控制器)
    – 回到指定视图控制器, 也就是不只弹出一个

    popToRootViewControllerAnimated:BOOL

    (弹出到根视图控制器)
    – 比如说你有一个“Home”键,也许就会实施这个方法了。

    setNavigationBarHidden:BOOL animated:BOOL

    (设置导航栏是否显示)
    – 如果你想隐藏导航栏,这就是地方了。参照Picasa的WebApp样式

    Navigation Controller 模式弹出新的Navigation Controller

    UINavigationController *navController = [[UINavigationController alloc]      initWithRootViewController:addViewController];

        [self.navigationController presentModalViewController:navController animated:YES];
       
    或:    SubView *printView=[[EIPrintPreprint alloc] initWithNibName:@"SubView" bundle:nil];    [self presentModalViewController:printView animated:YES];    [printView release];

    实现pushViewController:animated:的不同页面转换特效

    1. 首先要明确的是,不使用pushViewController的默认动画,所以在调用这个函数时,要将animated设置为NO.

    2. 使用普通的来CATransition实现转换效果,代码如下:

    CATransition *animation = [CATransition animation];

    [animation setDuration:0.3];

    [animation setType: kCATransitionMoveIn];

    [animation setSubtype: kCATransitionFromTop];

    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];

        

        [self.navigationController pushViewController:m_poseAddIssueViewController animated:NO];

        

        [self.navigationController.view.layer addAnimation:animation forKey:nil];

  • 相关阅读:
    《最小割模型在信息学竞赛中的应用》最大权闭合图
    《最小割模型在信息学竞赛中的应用》最优标号
    《最小割模型在信息学竞赛中的应用》网络战争
    P3254 圆桌问题
    P2766 最长不下降子序列问题
    P2754 星际转移问题
    洛谷P2756 飞行员配对方案问题
    状态压缩dp 炮兵阵地
    状态压缩—玉米田
    CCF 202006-2 稀疏向量
  • 原文地址:https://www.cnblogs.com/mac_arthur/p/1650762.html
Copyright © 2011-2022 走看看