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