国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

iOSUI基礎07

2019-11-14 18:34:52
字體:
來源:轉載
供稿:網友
  • TableView

    • 屬性

         // 設置每一行cell的高度   @PRoperty (nonatomic)CGFloat rowHeight;   // 設置每一組頭部的高度   @property (nonatomic)CGFloat sectionHeaderHeight;   // 設置分割線顏色   @property (nonatomic, retain) UIColor *separatorColor   // 設置表頭控件   @property (nonatomic, retain) UIView *tableHeaderView;   // 設置表尾控件   @property (nonatomic, retain) UIView *tableFooterView;   // 2.組頭組尾的高   self.tableView.sectionHeaderHeight = 55;   self.tableView.sectionFooterHeight = 22;   // 3.設置整個tablView的頭部/尾部視圖   self.tableView.tableHeaderView = [[UISwitch alloc] init];   self.tableView.tableFooterView = [UIButton buttonWithType:UIButtonTypeInfoDark];   // 4.設置我們分割線顏色(clearColor相當于取消系統分割線)   //self.tableView.separatorColor = [UIColor clearColor];  // 5.設置分割線樣式   self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    • 數據源方法
        //cell有多少組-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView //告訴tableView第section組有多少行-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section//告訴tableView每一行顯示什么內容(tableView的每一行都是UITableViewCell)-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath //告訴tableView第section組的頭部標題文字-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section // 告訴tableView第section組的尾部標題文字-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section//返回每一組的索引標題- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView // 返回每個cell的高度 -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath//刪除數據- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;//
    • 代理方法
       // 只要實現了這個方法,左滑出現按鈕的功能就有了(一旦左滑出現了N個按鈕,tableView就進入了編輯模式, tableView.editing = YES)         -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath     //左滑cell時出現什么按鈕       -(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath    {      UITableViewRowAction *action0 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"關注" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {        NSLog(@"點擊了關注");        // 收回左滑出現的按鈕(退出編輯模式)        tableView.editing = NO;    }];    UITableViewRowAction *action1 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"刪除" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {        [self.wineArray removeObjectAtIndex:indexPath.row];        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];    }];    return @[action1, action0];}    //代理方法獲取點滴選中行,行號    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;    //允許編輯選中行    - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath;
  • UITableViewCell

    • 屬性:
      //設置cell右邊的指示樣式//accessoryView的優先級 > accessoryType//cell.accessoryView = [[UISwitch alloc] init];@property (nonatomic) UITableViewCellAccessoryType    accessoryType;// default is UITableViewCellAccessoryNone. use to set standard type
    • Cell 創建

      • 注冊創建

        [self.tableview registerClass:[UITableViewCell class] forCellReuseIdentifier:ID];//注冊后可以直接從緩存中找創建好的UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
      • 非注冊創建

        • 先從緩存持中查找

           UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
        • 查不到在創建

           if (nil==cell) {cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID]; }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 共和县| 平塘县| 宁波市| 房产| 甘洛县| 乐安县| 达州市| 太保市| 福海县| 南川市| 常熟市| 普兰县| 汽车| 长宁区| 阿勒泰市| 海淀区| 平阳县| 卫辉市| 固安县| 文山县| 浪卡子县| 屏东县| 定西市| 莱州市| 务川| 泽普县| 陕西省| 额济纳旗| 若羌县| 太仓市| 新河县| 台东县| 汝州市| 和硕县| 大田县| 马边| 海安县| 夏邑县| 灵寿县| 昂仁县| 浦东新区|