• ios 开发学习笔记


    1. .xib文件为布局文件

      .h 为头文件  .m为实现文件

    2.Delegate委托

    3. 文件AppDelegate 主入口   viewcontroller

        .xib布局文件

       .storyboard

    .mm是oc和C++混编类型文件后缀,给编译器识别的

    4. 怎么样将UIViewController.m与.xib文件关联,是界面显示出来。

    1>.在项目文件夹上右键----->new File--------->ios Source---->创建 Ccoa Touch Class 文件,继承类为UIViewController,勾选 Alse create XIB file;系统会默认创建三个同名的.h .m .xib文件。这样UIViewController和.xib文件就是关联的了。

    2>.在AppDelegate.m中创建UIViewController。

    self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    CustomViewController* customViewController = [[CustomViewController alloc] initWithNibName:nil bundle:nil];  
    self.window.rootViewController= customViewController;
    
    self.window.backgroundColor=[UIColor whiteColor];
    [self.window makeKeyAndVisible];//这个一句必须要,用来将界面显示出来
    return YES;
    
    [===============================转载==================================================]
    
    个人感觉ios中的UIViewController和xib文件,分别相当于android的Activity 和Layout文件
    
    当时两者的关联比android稍微复杂些。
    
    ios上分别新建的UIViewController类和xib文件建立关联必须完成以下两步:
    
    1. 修改xib文件 (引用自:http://www.xcodechina.com/archiver/?tid-574.html)
    
    a. 点击我们要加载的 xib 文件
    
    b. 在右边选中 File's Owner
    
    c. 在 File's Owner 的 选项卡的“Custom Class” 属性设置中,将 Class 的值改成对应的 VC, 这里改成 你新建的UIViewController派生类,
    
    d. 这时候,在File's Owner 的 选项卡中, 就 会出现“待连接设置” 的 view 属性, 将此view属性关联道xib中任何一个view
    2. 在创建你的UIViewControler类对象是用下面构造函数:
    
    switchViewController = [[SwitchViewController alloc] initWithNibName:@"SwitchView" bundle:nil]; //@"SwitchView"为你的xib文件名
    
    这个有点类似Acitvity中setContentView。

    4.框架:Foundation------------核心框架,类似于Array之类都在里面

    Core Data-----------------------数据库

    Map Kit----------------------地图

    UIKit------------类似于Button,滑动条都在里面

    Core Mation-----------陀螺仪和加速计

    #import <Foundation/NSObject.h>
    
    定义接口
    @interface Core
    @end
    
    定义实现
    @implementation Core
    

      

    3.遇到的错误解决:

     1>undefined symbols for architecture x86_64:问题描述http://www.cnblogs.com/sevenyuan/p/4272554.html。1.把1.选中Targets—>Build Settings—>Architectures。把build active architectures only 改为 NO2. 把最下面的Valid Architectures中的arm64参数删掉就可以了或者:双击Architectures,选择other,删除$(ARCH_STANDARD),然后增加armv7和armv7s(写上:$(ARCHS_STANDARD_32_BIT))。3.clean 再build。

    2>’autorelease’ is unavailable: not available in automatic reference counting mode, ARC forbids explicit message send of ‘autorelease’:其实错误很明显,就是说,autorelease不能使用,原因在于我们之前创建当前iOS程序的时候,选择了“Use Automatic Reference Counting”,即使用了ARC,自动引用计数,所以此处,在写代码的时候,就不允许你再手动添加autorelease这个关键字了。对应的,编译器会帮你自己优化生成对应的释放内存的操作。所以,解决办法很简单,那就是直接删除autorelease这个关键字,变self.dateFormatter = [[NSDateFormatter alloc] init];在创建iOS项目时,如果选择了"Use Automatic Reference Counting",那么代码中,自然就不需要再写autorelease了。也可以在build setting中将 use autorelease设置为no

    3>找不到".h"文件,需要在build  Settings 中的Header Search Paths 中设置路径

  • 相关阅读:
    Visual Studio 2019 开发 Python 及
    Delphi 的环境配置
    Delphi 的 TMS 控件安装方法
    网络爬虫-书籍与框架
    建筑行业(项目管理) BI 数据可视化分析案例
    DeepNude(一健脱衣)的算法以及通用图像生成的理论与实践研究
    matlab生成HEX文件-任意信号 大于64K长度
    SDRAM总结
    function [ binary,decimal ] = num2binary16( number )
    任意时钟分频
  • 原文地址:https://www.cnblogs.com/1000pen/p/4485696.html
Copyright © 2020-2023  润新知