ios7

时间:2015-12-07 09:28:42

标签: objective-c ios7 uicollectionview

-(NSInteger)collectionView:(UICollectionView *)collectionView   numberOfItemsInSection:(NSInteger)section{

     if (recentEmojiArray.count == 0) {

        // Display a message when the table is empty                 

        UILabel *messageLabel1  = [[UILabel alloc]
        initWithFrame:CGRectMake(0, 0, clvRecent.bounds.size.width,
        clvRecent.bounds.size.height)];
        messageLabel1.text =@"No recent emojis.";
         [messageLabel1 sizeToFit];
         clvRecent.backgroundView = messageLabel1;

       return 0;                
     }
      else{
            clvRecent.backgroundView = nil;                       
            return recentEmojiArray.count;
      }
    }

仍显示带有消息"No recent emojis."的背景视图标签我试图将messageLable1文字重置为空白。但仍然只出现在iOS7iOS8正常工作

请帮助,提前致谢。

1 个答案:

答案 0 :(得分:0)

只需使用此

粘贴代码即可
-(NSInteger)collectionView:(UICollectionView *)collectionView   numberOfItemsInSection:(NSInteger)section{

     if (recentEmojiArray.count == 0) {

        // Display a message when the table is empty                 

        UILabel *messageLabel1  = [[UILabel alloc]
        initWithFrame:CGRectMake(0, 0, clvRecent.bounds.size.width,
        clvRecent.bounds.size.height)];
        messageLabel1.text =@"No recent emojis.";
         [messageLabel1 sizeToFit];
         clvRecent.backgroundView = messageLabel1;

     }
      else{
            clvRecent.backgroundView = nil;                       
      }
  return recentEmojiArray.count;

}