iOS中的小知识点
1.tableView隱藏滾動條
self.tableView.showsVerticalScrollIndicator = NO;2.關(guān)于屬性
使用assign: 對基礎(chǔ)數(shù)據(jù)類型 (NSInteger,CGFloat)和C數(shù)據(jù)類型(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];一般在請求服務(wù)器數(shù)據(jù)后,更新顯示使用
?
6.appearance統(tǒng)一設(shè)置外觀
//在appearance統(tǒng)一設(shè)置NSMutableDictionary *attrs = [NSMutableDictionary dictionary];attrs[NSFontAttributeName] = [UIFont systemFontOfSize:13];attrs[NSForegroundColorAttributeName] = [UIColor grayColor];//item的appearance外觀設(shè)置(條件限制:方法后面有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,調(diào)整內(nèi)部子視圖的位置
?
8.使自己的代碼只被調(diào)用一次
例如appearance統(tǒng)一設(shè)置一次就夠了
+ (void)initialize?
9.tableView中默認選中首行
//默認選中首行[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];?
?10.設(shè)置insert(在UITbaleView中導航欄擋住了顯示的內(nèi)容)
//設(shè)置insertself.automaticallyAdjustsScrollViewInsets = NO;self.tableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);?
?11.設(shè)置cell高度(默認cell高度為44)
self.tableView.rowHeight = 70;?
?12.獲取tableView當前的行號
self.tableView.indexPathForSelectedRow.row?
?
?
?
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/langji/p/5411271.html
總結(jié)
- 上一篇: Teamwork(The sixth d
- 下一篇: 中国网瘾群落调查