<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      iOS Autolayout 在tableView scrollView 適用 學(xué)習(xí)

       1  如何自動(dòng)適應(yīng)cell的高度

      autolayout  里面 使用 systemLayoutSizeFittingSize 方法 (系統(tǒng)通過 已知的完整的Constraints和view的屬性來計(jì)算高度)根據(jù)一個(gè)cell實(shí)例計(jì)算高度.  

      優(yōu)勢:不需要寫過多復(fù)雜的高度計(jì)算邏輯, 代碼簡潔.  強(qiáng)大

      (1)首先依舊要在下面代理方法里實(shí)現(xiàn)讀取cell 高度 heightForRowAtIndexPath:

      (2)計(jì)算高度  還是要考慮兩種情況

          第一 如果不知道高度,計(jì)算一遍,存儲(chǔ)(盡量只計(jì)算一次,然后保存高度,計(jì)算需要布局 也是一個(gè)效率問題)

          第二 知道高度 直接讀取

      (3)關(guān)于cell的讀取

      第一種  純代碼 寫法

      這種 是我純代碼開發(fā)中經(jīng)常用到的

         (1)cell 初始化要override 方法

       - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier  
       {  
              self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];  
              if (self)  {  
      
                  // TODO:cell頁面布局  
              }  
              return self;  
       }  

       (2)  dequeue 獲取cell 為空 要?jiǎng)?chuàng)建新cell

       

          static  NSString *cellIdentifier = @"AHFHomeListCell";
          AHFHomeListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
          if (!cell) {//需要判空 ,如果為空 需要?jiǎng)?chuàng)建cell initWithStyle:reuseIdentifier
      
              cell = [[AHFHomeListCell alloc] initWithStyle:UITableViewCellStyleDefault
      
                                            reuseIdentifier:cellIdentifier];
      
              [cell.topicView setHandleSeletedOptionBlock:^(TopicOptions *options, TopicListModel *listModel,BOOL isOnlyRead) {
      
                  NSString *optionId = isOnlyRead ? listModel.voted_option_id : options.option_id;
      
                  [self openArticleVCArticleId:listModel.article_id img:listModel.banner andOptionId:[optionId integerValue] andIsRead:isOnlyRead];
      
              }];
          }

       

      第二種 代碼 加 注冊cell

      為tableView注冊cell,使用registerClass:forCellReuseIdentifier:方法向數(shù)據(jù)源注冊cell(注意是Class 即 [xxxxxCell class]

      //register cell:
      static
      NSString *kCellIdentify = @"MyTableViewCell"; [self.tableView registerClass:[xxxxxCell class] forCellReuseIdentifier:kCellIdentify];
      //
      cellForRowAtIndexPath:
      //第一種實(shí)現(xiàn)
      //
      dequeueReusableCellWithIdentifier:forIndexPath: 方法會(huì)直接調(diào)用注冊(所以必須有注冊方法),不需要判斷cell空值了就
      MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyTableViewCell" forIndexPath:indexPath];
      //第二種實(shí)現(xiàn)
      //dequeueReusableCellWithIdentifier:可以注冊 之后 不需要判空,可以不注冊需要判空如果為空 就創(chuàng)建新cell
      static MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentify];
      if (!cell) {
      //如果使用 registerClass: 注冊過 則此處不需要處理 否則需要?jiǎng)?chuàng)建cell initWithStyle:reuseIdentifier
      } 
      //TODO:填充UI數(shù)據(jù)

      第三種 使用xib 加 注冊 cell

      使用 tableView 的 registerNib:forCellReuseIdentifier:方法向數(shù)據(jù)源注冊cell

      //register cell:

      [self.tableView registerNib:[UINib nibWithNibName:@"MyTableViewCell" bundle:nil] forCellReuseIdentifier:kCellIdentify];
      //cellForRowAtIndexPath:
      實(shí)現(xiàn)規(guī)則同第二種方法里面的相應(yīng)代碼講解

       

      關(guān)于兩種注冊: registerNib: 與 registerClass: 為什么可以不用去判空 ?

      因?yàn)闊o可復(fù)用cell時(shí)runtime將使用注冊時(shí)提供的資源去新建一個(gè)cell并返回

        2   如何在ScrollView中使用Autolayout (這里用Masonry 純代碼實(shí)    CGFloat scrollWidth = HorizontalFrom750(225 + 20);

          CGFloat scrollHeight =VerticalFrom750(290);
          pageWidth = scrollWidth;
      //設(shè)置scrollView 約束 [self.scrollView mas_makeConstraints:
      ^(MASConstraintMaker *make) { make.center.equalTo(self); make.width.equalTo(@(scrollWidth)); make.height.equalTo(@(scrollHeight)); }];
      //使用containView 作為容器View 在容器View里面塞入目標(biāo)滾動(dòng)的子對象 UIView
      *containView = UIView.new; [self.scrollView addSubview:containView]; [containView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.scrollView); make.height.equalTo(self.scrollView); }];
      self.cardViewArray
      = [NSMutableArray array]; self.cardButtonArray = [NSMutableArray array]; // 目標(biāo)滾動(dòng)元素 一個(gè)一個(gè) add 在 conttainView上 注意邊界問題 UIView *lastView; CGFloat leftPadding = 0; //邊界 for (int i = 0; i < pageCount; i ++) { UIView *backView = UIView.new; [containView addSubview:backView]; [backView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(containView); make.width.equalTo(@(scrollWidth)); make.height.equalTo(self.scrollView.mas_height); if (lastView) { make.left.equalTo(lastView.mas_right); } else { make.left.equalTo(@(leftPadding)); } }]; lastView = backView; MethodMediaModel *music = self.musicArray[i]; MusicCardView *cardView = [[MusicCardView alloc]initWithFrame:CGRectZero]; [cardView setCardTitle:music.title imgUrl:music.img_url]; [cardView.playButton addTarget:self action:@selector(playAction:) forControlEvents:UIControlEventTouchUpInside]; cardView.playButton.tag = i; [cardView.playButton setObj:music]; [backView addSubview:cardView]; [cardView mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(backView); make.left.equalTo(backView).offset(10); make.right.equalTo(backView).offset(- 10); make.height.equalTo(backView); }]; [self.cardViewArray addObject:backView]; [self.cardButtonArray addObject:cardView.playButton]; } [lastView mas_updateConstraints:^(MASConstraintMaker *make) { make.right.equalTo(containView.mas_right);//邊界
      }];

        3   使用Autolayout做動(dòng)畫

           //TODO:

        4      Autolayout在IOS6上的坑

          //TODO:

       

      參考:

       

      https://blog.cnbluebox.com/blog/2015/02/02/autolayout2/

      http://blog.csdn.net/youngsblog/article/details/44536143

       

      posted on 2017-05-03 11:05  ACM_Someone like you  閱讀(312)  評論(0)    收藏  舉報(bào)

      導(dǎo)航

      主站蜘蛛池模板: 亚洲春色在线视频| 人人澡超碰碰97碰碰碰| 亚洲一二三区精品美妇| 亚洲精品日韩在线丰满| 悠悠人体艺术视频在线播放| 2020国产欧洲精品网站| 国产成人人综合亚洲欧美丁香花| 日本a在线播放| 欲乱人妻少妇邻居毛片| 黄色亚洲一区二区在线观看| 女人高潮被爽到呻吟在线观看| 国产va免费精品观看| 四虎成人精品在永久在线| 夜夜添狠狠添高潮出水| 亚洲18禁一区二区三区| 亚洲国产精品久久无人区| 久久亚洲av成人无码软件| 无码一区二区三区AV免费| 亚洲乱妇熟女爽到高潮的片| 日韩一区二区三区亚洲一| 日本不卡片一区二区三区| 毛片久久网站小视频| 久久se精品一区二区三区| 国产精品99区一区二区三| 亚洲免费视频一区二区三区| 色综合久久婷婷88| 视频二区中文字幕在线| 国产片一区二区三区视频| 精品亚洲国产成人av制服| 又爽又黄又无遮挡的激情视频| 亚洲av综合久久成人网| 亚洲国产成人久久一区久久| 久久婷婷大香萑太香蕉AV人| 亚洲精品一二三伦理中文| 欧美浓毛大泬视频| 国产视频有码字幕一区二区| 久久夜夜免费视频| 国产中文三级全黄| 丹江口市| 99热精品毛片全部国产无缓冲| 亚洲 欧美 唯美 国产 伦 综合|