自动布局的UILabel高度的第二种观点appearence改变 [英] Autolayout UILabel height changes on second view appearence

查看:232
本文介绍了自动布局的UILabel高度的第二种观点appearence改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TableHeaderView动态的UILabel(<一个href=\"http://stackoverflow.com/questions/22793078/hide-view-and-reposition-other-view-with-autolayouts\">see这个问题),一切都很好,而且很好,但如果我的标签的文本设置为 @标签保留,它有当文本是在高度的大小。

I have a dynamic UILabel in a TableHeaderView (see this question) and everything is okay and fine, but if I set the text of the label to nil or @"" the label keeps the size of the height that it had when the text was in.

我改变了在不同的viewController我是 presenting模态的文字。所以我想它告诉你3个步骤:

I'm changing the text in a different viewController that I'm presenting modally. So i would like to show it you in 3 steps:

原来的状态

设置文本 @,后

After setting the text to @""

在这个步骤中,presented的的viewController删除文本,然后我解聘的viewController回去了这一观点。

In this step I presented the viewController to remove the text and then I dismiss the viewController to go back to this View.

重新出现这个视图

所以我要打开编辑的viewController只是再次驳回。然后,它是像我想..:

So I have to open the editing viewController to just dismiss it again. Then it is like i want it to..:

任何想法,为什么?我重新大小的TableViewHeader这样在 viewWillAppear中方法:

Any ideas why? I'm re-sizing the TableViewHeader like this in the viewWillAppear method:

- (void)resizeTableViewHeader
{
    //GET THE SIZE OF THE CONTAINER
    CGSize fittingSize = [self.header systemLayoutSizeFittingSize: UILayoutFittingCompressedSize];
    self.header.frame = CGRectMake(0, 0, 320, fittingSize.height);
    self.tableView.tableHeaderView = self.header;
}

任何想法,为什么我要访问的查看两次?

Any idea why I have to visit the View twice?

推荐答案

也许需要更新约束某处,或 layoutIfNeeded 。其他的解决办法可以在我的其他答案被发现。

Maybe it needs constraints updating somewhere, or layoutIfNeeded. Other solution could be found in my other answer.

这篇关于自动布局的UILabel高度的第二种观点appearence改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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