未设置表的动态高度 [英] Dynamic height of table is not set

查看:61
本文介绍了未设置表的动态高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置表的动态高度。但是当我记录表格的高度它显示我动态高度但没有设置为实际表格时它不起作用。

I am trying to set dynamic height of table. But it is not working when I log height of table it is showing me dynamic height but not set to actual table.

这是我的代码:

CGRect table_frame;
table_frame=table_sender.frame;
NSLog(@"table fram: %f",table_frame.size.height); //got table height 444
float height = [senderHistoryDataArray count]  * 40 +40 ; // 4*25.00
NSLog(@"height of table: %f",height);  //got this height 200
if(height>=444){
    table_frame.size.height=444;
}
else{
    table_frame.size.height=height;
    NSLog(@"height set");  //also displying this line in log
}

table_sender.frame=table_frame;
[table_sender reloadData];

Out Put:

Out Put:

当我取消选中自动布局时,它会起作用,但它只显示比以前更多的部分。

when I uncheck autolayout it will work but it is just showing more part than previous.

推荐答案

如果您正在使用AutoLayout,那么您无法设置框架 - 如果您这样做,您将获得wiered行为

if you are using AutoLayout then you can't set frames - if you do that you get wiered behaviour

Autolayout是一种相对的在屏幕上放置UI组件的方法。
例如,我身后的支架100px和左边界的20px(这里我使用了像素 - 你可以想象米被认为是游乐场)

Autolayout is sort of relative approach of placing UI components on screen. For e.g Stand 100px behind me and 20px from left boundary (here i have used pixel - you can think of as meters think of it as playground)

这篇关于未设置表的动态高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆