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];
    复制代码
  • 相关阅读:
    Python 入门的一些练习题
    Parallel Data Augmentation for Formality Style Transfer 阅读
    Windows Internals 笔记——用户模式下的线程同步
    RSA算法原理(转)
    Ubuntu Git Server 搭建(Gitosis)
    Linux Make 报错:make: *** /lib/modules/3.10.0-1127.el7.x86_64/build: no such file or directory. stop.
    Centos 配置串口连接
    编写一个程序,将字符数组s2中的全部字符复制到字符数组s1中,不用strcpy函数。复制时,‘’也要赋值过去。''之后的字符不复制
    编写一个程序,将连个字符串s1和s2比较,如果s1 > s2,输出一个整数;若s1 = s2,输出0;若s1 < s2,输出一个负数。不要用strcpy函数。两个字符串用gets函数读入。输出的正数或负数的绝对值应是相比较的两个字符串相对应字符的ASCII码的差值。
    编一程序,将两个字符串连接起来,不要用strcat函数
  • 原文地址:https://www.cnblogs.com/LiLihongqiang/p/5782701.html
Copyright © 2011-2022 走看看