zoukankan      html  css  js  c++  java
  • iOS开发基础知识--碎片2

    iOS开发基础知识--碎片2

     

    六:获得另一个控件器,并实现跳转

    复制代码
    UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
      
    UIViewController *registerViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"registerViewController"];
        
        
    registerViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        
    [self presentViewController:registerViewController animated:YES completion:^{
            
    NSLog(@"Present Modal View");
        
    }];
    复制代码

     另一种用segue连接:

    如果在storyboard中当前的ViewController和要跳转的ViewController之间的segue之间存在,则可以执行performSegueWithIdentifier:sender:这个方法实现跳转。

      比如:[self performSegueWithIdentifier:@"go" sender:self];

         其中,go为自己定义的segue标识符。

    其中registerViewController是第二个视图中标识检查器Storyboard ID的值

    七:判断IOS版本

    判断IOS是不是7.0以后的

    if([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0) {

    }

    八:Button不同状态下背景图片

     [_registerButton setBackgroundImage:[UIImage imageNamed:@"3signbutton-n.png"] forState:UIControlStateNormal];

     [_registerButton setBackgroundImage:[UIImage imageNamed:@"3signbutton-s.png"] forState:UIControlStateHighlighted];

    九:判断设备是3.5寸还是4寸

    if ([[UIScreen mainScreen] currentMode].size.height == 480||[[UIScreenmainScreen] currentMode].size.height == 960)

    {    

    //这是3.5寸的iPhone设备

    }

    else

    {     //这是4寸的iPhone设备 }

    十:viewDidLoad中调用

    无论你是通过xib文件还是重写loadView方法创建UIViewController的view,在view创建完毕后,最终都会调用viewDidLoad方法,一般我们会在这里做界面上的初始化操作,比如往view中添加一些子视图、从数据库或者网络加载模型数据装配到子视图中

    复制代码
    - (void)viewDidLoad
     {
         [super viewDidLoad];
         
         // 添加一个按钮
         UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
         [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
         [self.view addSubview:button];
     }
    复制代码

    十一:树形结构导航问题(UINavigationController)

    1:如何修改第二页的返回back文字

    应该在第一页的viewDidLoad里面进行修改(假设从A界面push到B界面,希望改变B界面的返回按钮标题,则在A界面中加入代码),代码如下:

    复制代码
    -(void)viewDidLoad
    {
    UIBarButtonItem *backItem = [[[UIBarButtonItem alloc] init] autorelease];
     
    backItem.title = @"返回";
     
    self.navigationItem.backBarButtonItem = backItem;
    }
    复制代码

    2:如何增加一个控件在标头

    在本页的viewDidLoad里面进行增加;代码如下:

    复制代码
    -(void)viewDidLoad
    {
    UIBarButtonItem* Done=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(DownShow)];
    self.navigationItem.rightBarButtonItem=Done;
    }
    
    -(void)DownShow
    {
    
    }
    复制代码

    其中按键类型如下(带有不同的图标):

    复制代码
        UIBarButtonSystemItemDone,
        UIBarButtonSystemItemCancel,
        UIBarButtonSystemItemEdit,  
        UIBarButtonSystemItemSave,  
        UIBarButtonSystemItemAdd,
        UIBarButtonSystemItemFlexibleSpace,
        UIBarButtonSystemItemFixedSpace,
        UIBarButtonSystemItemCompose,
        UIBarButtonSystemItemReply,
        UIBarButtonSystemItemAction,
        UIBarButtonSystemItemOrganize,
        UIBarButtonSystemItemBookmarks,
        UIBarButtonSystemItemSearch,
        UIBarButtonSystemItemRefresh,
        UIBarButtonSystemItemStop,
        UIBarButtonSystemItemCamera,
        UIBarButtonSystemItemTrash,
        UIBarButtonSystemItemPlay,
        UIBarButtonSystemItemPause,
        UIBarButtonSystemItemRewind,
        UIBarButtonSystemItemFastForward,
        UIBarButtonSystemItemUndo,
        UIBarButtonSystemItemRedo,
        UIBarButtonSystemItemPageCurl//只能在ToolBar上显示
    复制代码

    3:如何修改标头的色彩

    self.navigationController.navigationBar.tintColor=[UIColor redColor];

    4:增加其它UISegment,UISwith控件

    在本页viewDidLoad中增加如下代码,

    复制代码
        UISegmentedControl *mySegment;
    
        mySegment = [[UISegmentedControl alloc] initWithFrame:CGRectMake(218.0f, 8.0, 100.0f, 30.0f)];
     
        [mySegment insertSegmentWithTitle:@"分配" atIndex:0 animated:YES];
     
        [mySegment insertSegmentWithTitle:@"处理" atIndex:1 animated:YES];
     
        mySegment.segmentedControlStyle = UISegmentedControlStyleBar;
     
        mySegment.selectedSegmentIndex = 0;
     
        [self.navigationController.navigationBar addSubview:mySegment];
    复制代码
  • 相关阅读:
    不足百行代码 实体数组转DataTable通用类
    【翻译】WEB安全设计规范(4.1)
    也为读者说几句(兼为什么要骂烂书译者)
    重用之前应仔细分析问题用错轮子有感
    最长代码有多长:不符[单一职责原则(SRP)]的常见设计
    "千里之堤毁于蚁穴"重点项目不能交付之谜(一)泥淖中的验收测试
    企业快速开发框架基于配置文件
    从面试题看高级软件工程师需要哪些技艺
    面试英语【转】
    测试
  • 原文地址:https://www.cnblogs.com/LiLihongqiang/p/5782701.html
Copyright © 2011-2022 走看看