【发布时间】:2017-12-18 14:13:30
【问题描述】:
查看下图,
显示“无记录”标签。
我想改变它的位置,即我想向上移动一点,所以当 uitableview 加载时它会隐藏。
当我创建项目时,它工作正常。在我为排序和过滤添加新视图(新导航)后,标签位置更改为向下,现在它没有隐藏在加载器后面。
为此编写的代码是,
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSInteger numOfSections = 0;
if ([_mutableArray count]==0)
{
UILabel *noDataLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, tableView.bounds.size.height)];
noDataLabel.text = NSLocalizedString(@"No Records..!!!",nil);
noDataLabel.textColor = [UIColor blackColor];
noDataLabel.textAlignment = NSTextAlignmentCenter;
tableView.backgroundView = noDataLabel;
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}
else
{
tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
numOfSections = 1;
tableView.backgroundView = nil;
}
return numOfSections;
}
有没有办法根据我们的选择调整标签??
【问题讨论】:
-
在加载时隐藏标签更简单。
-
在获取数据之前不要设置数据源,或者调用reload data。
标签: ios objective-c uitableview position uilabel