1. UITabBarController UINavigationController UIViewController
UITableView
缺少一份了堅持!
欲帶王冠,必先承其重!
你放縱的每一秒,又有多少人在拼命!
你所聽到的忠告,是別人走了多少個彎路,總結出來的!
2.協議<UITableViewDelegate,UITableViewDataSource>
以爲是你 家的味道 兄弟乾杯
3. _sectionList=@[@[@"搜索"],@[@"設置",@"狀態"]];
[tabView release];
}
//有幾個section
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return _sectionList.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray *array= _sectionList[section];
return array.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.textLabel.text=_sectionList[indexPath.section][indexPath.row];
return cell;
[cell release];
}
4.獲取當前工程下目錄的路徑
NSString *path=[[NSBundle mainBundle]pathForResource:@"font" ofType:@"plist"];
5.-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
自定義section頭部視圖
.tableHeaderView 定義整個視圖的頭部視圖
6._fonts=[[UIFont familyNames]retain] 記住一定要retain 不然的話會出野指針
7.static NSString *identifier=@"myCell";
//查詢池子中是否有空閒的單元格
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell==Nil) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
cell.textLabel.font=[UIFont fontWithName:_fonts[indexPath.row] size:14];
cell.textLabel.text=_fonts[indexPath.row];
單元格的重用法
8.plist文件 格式第一個爲root默認 字典
9.背景透明
[UIColor clearColor]
10.高度自適應 核心代碼
-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *text=[_data objectAtIndex:indexPath.row];
CGSize size=[text sizeWithFont:[UIFont systemFontOfSize:14]constrainedToSize:CGSizeMake(300, 1000)];
return size.height+20;
}
11.NSString *text=[_data objectAtIndex:indexPath.row]; 這是取得別人的值 不是重新定義的數
12.單元格複用問題
if (self.indexPath != nil) {
if (self.indexPath.section == indexPath.section && self.indexPath.row == indexPath.row) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
} else {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
當前選用的是否等於將要顯示的,是的話一樣
不是的話不一樣
//當前選中的事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//設置輔助視圖的樣式
cell.accessoryType = UITableViewCellAccessoryCheckmark;
//記錄當前選中單元格的索引
self.indexPath = indexPath;
}
//上一次選中的事件 處理上一次 輔助圖標不消失問題
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//設置輔助視圖的樣式
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
13.UISearchBar 搜索框
14.搜索過濾
//初始化謂詞的時候不能加佔位符 這是bug
NSString *p=[NSString stringWithFormat:@"SELF LIKE[c]'%@*'",text];
NSPredicate *predicate=[NSPredicate predicateWithFormat:p];
self.filterData=[_fonts filteredArrayUsingPredicate:predicate];
表視圖
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
【ios 彙總 你可能不知道的調試技巧】
听着rap写代码
2020-02-20 22:14:16
textFiled要注意的地方
moon_shine
2020-06-24 18:40:42
AWS S3服務
阿飞小伙子_blogs
2020-06-04 13:28:05
UIScrollView頻道滑動(授人以魚,不如授人以漁)
hherima
2020-02-21 23:59:46
SDWebImage源碼解析
阿飞小伙子_blogs
2019-06-22 01:56:17
【精】iOS知識樹,知識點(包括對象、Block、消息轉發、GCD、運行時、runloop、動畫、Push、KVO、tableview,UIViewController、提交AppStore)
hherima
2018-09-04 22:03:01
IOS 開發,調用打電話,發短信,打開網址
moon_shine
2018-08-31 21:25:18
iOS系統架構和常用框架
陈荣科
2018-08-31 01:08:49
ios 內購服務器驗票(漏單處理)
听着rap写代码
2018-08-28 22:52:36
UIScrollView的基本用法
逝华_浮梦
2018-08-28 06:52:14