iOS中的小知识点
1.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中導航欄擋住了顯示的內容)
//設置insertself.automaticallyAdjustsScrollViewInsets = NO;self.tableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);?
?11.設置cell高度(默認cell高度為44)
self.tableView.rowHeight = 70;?
?12.獲取tableView當前的行號
self.tableView.indexPathForSelectedRow.row?
?
?
?
?
?
?
轉載于:https://www.cnblogs.com/langji/p/5411271.html
總結
 
                            
                        - 上一篇: Teamwork(The sixth d
- 下一篇: 中国网瘾群落调查
