我有一个问题。在我的应用程序中,我有一个带有列表的 TableView,当我删除最后一条记录时,我希望在 TableView 上显示“没有更多数据”。谢谢!
Best Answer-推荐答案 strong>
- (NSInteger)numberOfSectionsInTableViewUITableView *)tableView
{
if(self.searchUserResultList count==0))
{
// Display a message when the table is empty
UILabel *messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.view.center.x-15, self.view.frame.size.height/2 , self.view.bounds.size.width, self.view.bounds.size.height)];
messageLabel.autoresizingMask=UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
messageLabel.text = @"NO SEARCH RESULTS" ;
messageLabel.textColor = [UIColor whiteColor];
messageLabel.numberOfLines = 0;
messageLabel.textAlignment = NSTextAlignmentCenter;
messageLabel.font = [UIFont fontWithName"alatino-Italic" size:23];
[messageLabel sizeToFit];
messageLabel.tag = 222;
messageLabel.frame = CGRectMake(self.view.center.x-(messageLabel.frame.size.width/2), self.view.frame.size.height/2, messageLabel.frame.size.width, messageLabel.frame.size.height);
[self.view addSubview:messageLabel];
self.tableView.hidden = YES;
return 0;
}
for (UIView* b in self.view.subviews)
{
if(b.tag == 222)
{
[b removeFromSuperview];
}
}
self.tableView.hidden = NO;
return 1;
}
关于ios - 没有条目的 UITableView,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/30299817/
|