简体   繁体   English

在uiview中插入自定义uitableviewcell子视图

[英]insert a custom uitableviewcell subview in a uiview

I have a UIView that holds a UITableView, however the UITableView has a 30 pxl gap at the top in which i would like to add a static UITableViewCell programmatically. 我有一个拥有UITableView的UIView,但是UITableView在顶部有30 pxl的间隙,我想在其中以编程方式添加静态UITableViewCell。

I have tried to do this but I cannot seem to get it to appear, this is the code I am using I am not 100% sure if this is correct as its the first time trying it but to my knowledge it seems like it should be displaying. 我已经尝试执行此操作,但是似乎无法显示它,这是我正在使用的代码,我不是100%确信这是正确的,因为它是第一次尝试,但是据我所知,似乎应该是显示。

- (void)viewDidLoad
{
    [super viewDidLoad];

[selectAllCell setFrame:CGRectMake(0.0, 20.0, 320.0, 80.0)];
[selectAllCell.textLabel.text isEqualToString:@"all"];
[self.view insertSubview:selectAllCell aboveSubview:subModelTableView];

//.. other stuff
}

everything else in this view works perfectly.. so just wondering how I can get this uitableviewcell to display. 此视图中的其他所有内容都可以正常工作..所以,我想知道如何才能显示此uitableviewcell。

EDIT, I have updated the code in my viewDidLoad method but still I am not having any luck with this dran thing. 编辑,我已经更新了我的viewDidLoad方法中的代码,但仍然没有运气。

Why would you use a table view cell outside a table view? 为什么要在表格视图之外使用表格视图单元格? Just slap a UIView with an embedded button over the empty area. 只需在空白区域上打一个带有嵌入式按钮的UIView。 If that doesn't meet your needs for some reason, a fairly simple UIView or UIControl subclass should get the job done. 如果由于某种原因不能满足您的需求,则应该使用相当简单的UIView或UIControl子类来完成工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM