在UITableView上面添加UIView
问题描述:
我目前在UITableView上面添加UIView。它的工作原理,但看起来像空的UITableViewCell的下方会出现这样的:在UITableView上面添加UIView
还有就是我的第二个观点(.m文件)的代码:
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
NSLog(@"Calld");
self.backgroundColor = [UIColor whiteColor];
[self addLabel];
return self;
}
-(void)addLabel{
UILabel *fromLabel = [[UILabel alloc]initWithFrame:CGRectMake(8, 220, 304, 128)];
fromLabel.text = @"(Щелкните на экран, чтобы добавить задачи)";
fromLabel.numberOfLines = 3;
fromLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines; // or UIBaselineAdjustmentAlignCenters, or UIBaselineAdjustmentNone
fromLabel.adjustsFontSizeToFitWidth = YES;
fromLabel.adjustsLetterSpacingToFitWidth = YES;
fromLabel.minimumScaleFactor = 10.0f/12.0f;
fromLabel.clipsToBounds = YES;
fromLabel.backgroundColor = [UIColor clearColor];
fromLabel.textColor = [UIColor blackColor];
fromLabel.textAlignment = NSTextAlignmentLeft;
[self addSubview:fromLabel];
}
及主要观点:
InitialView *initView = [[InitialView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
[self.view addSubview:initView];
如何删除该空行,然后删除视图并再次显示表?
答
在您的情况下,您可以从标签高度增加或设置InitialView背景色来隐藏这些空行。 如果你想删除那些把你的控制器放在你有表格视图的地方。
yourTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
并删除您的视图,使您的tableview再次可见使用。
[initView removeFromSuperview];
答
您不需要删除空行或视图。 只是使的tableview隐藏直到数据未加载 - 在viewWillLoad
填充的tableview后,你重装tableview中,让tableview.hidden = NO;
默认情况下,空行会显示,直到除非你给的tableview的分隔线颜色是clearcolor。