【发布时间】:2018-06-05 02:30:23
【问题描述】:
我是 iOS 编程新手,我已经实现了UITableviewController。我把UIView 放在UITableView 里面。我在UIView 中设计了标签、文本字段和表格视图。这里我的问题是,当我根据数组计数增加动态表格视图时,我也想增加我的UIView 高度。我不知道该怎么做??下面是我的设计结构,
UITableViewController---
UIView----- (1)
Label---Label (2)
label---Label (3)
label--- (4)
UItableview (5)
textfield (6)
textfield (7)
and so on
下面我已经成功增加了(5)高度,我也想增加(1)高度我不知道该怎么做??有人可以为此提出解决方案吗?我已经尝试了下面的代码。
-(void)viewDidLayoutSubviews{
CGFloat numberofrows=creditList.count;
height = numberofrows*propertytable.rowHeight;
_tableviewheight.constant = height;
propertytable.frame =CGRectMake(propertytable.frame.origin.x,propertytable.frame.origin.y, propertytable.frame.size.width,_tableviewheight.constant);
CGRect myviewframe=mainview.frame;
NSLog(@"The myviewframe value is %f",myviewframe.size.height);
mainview.translatesAutoresizingMaskIntoConstraints=YES;
myviewframe.size.height=5000;
mainview.frame=myviewframe;
mainview.frame = CGRectMake(0,0,mainview.frame.size.width, 5000);
mainview.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
mainview.contentMode = UIViewContentModeScaleAspectFit;
[mainview layoutIfNeeded];
}
【问题讨论】:
-
UILabel(1) 和 UILabel(2) 是静态的还是动态的?
-
为什么在表格视图控制器中使用另一个表格视图。您可以使用部分,或者如果第一个视图是静态的,则将其作为表视图标题。您可以将 uiview 拖到表格视图中。如果您知道自动布局表格视图单元格的动态高度非常容易。
-
它不是tableviewcontroller,我使用tableview 我想动态填充数组值,为什么我使用??
-
我提到数字是静态的 我将我的 ui 设计到视图中。唯一 (5) 表视图是动态的
-
在增加 (5) 高度后,我无法滚动到底部,因为我还想增加我的 uiview 高度。
标签: ios objective-c iphone uitableview uiview