Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c ios7中的集合视图背景视图_Objective C_Ios7_Uicollectionview - Fatal编程技术网

Objective c ios7中的集合视图背景视图

Objective c ios7中的集合视图背景视图,objective-c,ios7,uicollectionview,Objective C,Ios7,Uicollectionview,“静止背景视图”标签上显示消息“无近期表情。”我试图将消息标签1文本重置为空白。但仍然只出现在iOS7中,而在iOS8中,其工作正常 请帮忙,提前谢谢。只需将您的代码与此粘贴在一起即可 -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ if (recentEmojiArray.count == 0) {

“静止背景视图”标签上显示消息
“无近期表情。”
我试图将
消息标签1
文本重置为空白。但仍然只出现在
iOS7
中,而在
iOS8
中,其工作正常


请帮忙,提前谢谢。

只需将您的代码与此粘贴在一起即可

-(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;
      }
    }

你能告诉我们你是如何得到recentEmojiArray.count的吗?我正在同一个控制器中添加recentEmojiArray并重新加载集合视图。当你重置为其他字符串时,messageLabel1文本是否不变?@Mithun是我重置messageLabel1.text=@“但不起作用……仅在ios7中。@ChandanPrajapati在等待元素时,你能放置一个断点并检查数组中是否有元素吗?当然,这不是他只是还原了你的实现,结果是一样的
-(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;

}