zoukankan      html  css  js  c++  java
  • nib文件的注册及加载

    1,注册
    [(UIView *)view registerNib:[UINib nibWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle] forCellReuseIdentifier:(NSString *)identifier];
     
    2,加载
    cell = [[[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil] lastObject];
    自定义的空间一般采用加载nib文件的形式创建,用new创建没有定义好的布局。
     
    其中,- (NSArray *)loadNibNamed:(NSString *)name
                        owner:(id)owner
                      options:(NSDictionary *)options
    的作用是Unarchives the contents of a nib file located in the receiver's bundle.
     
    3,NSBundle的作用
    作用:NSBundle用来管理项目中的资源文件,NSBundle实体可以定位项目中用到的资源,动态加载或者卸载可执行代码,起到辅助定位的功能。个人觉得英文版更能解释这个概念。
    NSBundle : An NSBundle object represents a location in the file system that groups code and resources that can be used in a program. NSBundle objects locate program resources, dynamically load and unload executable code, and assist in localization. 
    若为nil,则默认为mainBunble。
  • 相关阅读:
    linux 时间设置
    linux
    linux 关闭防火墙
    GIS-008-ArcGIS JS API 全图
    GIS-007-Terrain跨域访问
    GIS-006-ArcGIS API 空间关系
    Python 中文乱码
    GIS-005-Dojo & jQuery 事件处理
    GIS-004-Cesium版权信息隐藏
    GIS-003-在线地图下载及应用
  • 原文地址:https://www.cnblogs.com/lxd2502/p/5075513.html
Copyright © 2011-2022 走看看