iOS中的小知识点
2016-04-20 09:37
936 查看
1.tableView隐藏滚动条
2.关于属性
使用assign: 对基础数据类型 (NSInteger,CGFloat)和C数据类型(int, float, double, char, 等等)
使用copy: 对NSString
使用retain(strong): 对其他NSObject和其子类
3.注册cell
4.复用cell
5.刷新页面
一般在请求服务器数据后,更新显示使用
6.appearance统一设置外观
7.使用自己自定义的tabbar
在自己的tabber类中
利用- (void)layoutSubviews,调整内部子视图的位置
8.使自己的代码只被调用一次
例如appearance统一设置一次就够了
9.tableView中默认选中首行
10.设置insert(在UITbaleView中导航栏挡住了显示的内容)
11.设置cell高度(默认cell高度为44)
12.获取tableView当前的行号
self.tableView.showsVerticalScrollIndicator = NO;
2.关于属性
使用assign: 对基础数据类型 (NSInteger,CGFloat)和C数据类型(int, float, double, char, 等等)
使用copy: 对NSString
使用retain(strong): 对其他NSObject和其子类
3.注册cell
//注册cell [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([DDZRecommendCategoryCell class]) bundle:nil] forCellReuseIdentifier:@"category"];
4.复用cell
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"category"];
5.刷新页面
[self.tableView reloadData];
一般在请求服务器数据后,更新显示使用
6.appearance统一设置外观
//在appearance统一设置 NSMutableDictionary *attrs = [NSMutableDictionary dictionary]; attrs[NSFontAttributeName] = [UIFont systemFontOfSize:13]; attrs[NSForegroundColorAttributeName] = [UIColor grayColor]; //item的appearance外观设置(条件限制:方法后面有UI_APPEARANCE_SELECTOR) UITabBarItem *item = [UITabBarItem appearance]; [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
7.使用自己自定义的tabbar
//更换tabBar(利用KVC直接更改成员变量) [self setValue:[[DDZTabBar alloc] init] forKey:@"tabBar"];
在自己的tabber类中
利用- (void)layoutSubviews,调整内部子视图的位置
8.使自己的代码只被调用一次
例如appearance统一设置一次就够了
+ (void)initialize
9.tableView中默认选中首行
//默认选中首行 [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
10.设置insert(在UITbaleView中导航栏挡住了显示的内容)
//设置insert self.automaticallyAdjustsScrollViewInsets = NO; self.tableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
11.设置cell高度(默认cell高度为44)
self.tableView.rowHeight = 70;
12.获取tableView当前的行号
self.tableView.indexPathForSelectedRow.row
相关文章推荐
- iOS 数据缓存
- iOS选中文字点击learn崩溃
- ios常用三方资源
- 【代码笔记】iOS-利用图片序列创建动态图片效果
- iOS巅峰之跑马灯
- ios,使用CocoaPods做第三方库的依赖管理
- iosGCD其一
- Cordova - 使用Cordova开发iOS应用实战4(调用摄像头拍照,并编辑)
- IOS开发基础知识--碎片37
- 分享一下自己ios开发笔记
- iOS的自动布局
- iOS 状态栏管理
- iOS 设置代理过程
- iOS 页面间传值 之 单例传值 , block 传值
- iOS 页面间传值 之 属性传值,代理传值
- iOS xml解析
- iOS 沙盒路径获取,创建文件
- iOS JSON 数据解析
- ios中获取各种文件的目录路径方法
- ios 缺少合规证明