[英]IOS/Autolayout: Change to Presenting View After Presented Controller Dismissed
I am trying to get autolayout to work properly on a view controller with a scrollview. 我正在尝试使自动布局在带有scrollview的视图控制器上正常工作。 When I load the view controller the first time, it is not doing what I want. 第一次加载视图控制器时,它没有执行我想要的操作。 However, if I launch a second modal VC--which happens to be an Edit VC and then dismiss it, without doing anything else, the original VC lays out properly (the way I want). 但是,如果我启动第二个模式VC(恰好是Edit VC)然后不做任何其他操作就将其关闭,则原始VC会正确布局(我想要的方式)。
At first, the size of a textview is not adapted to its content but merely reflects is placeholder view in storyboard. 首先,文本视图的大小不适合其内容,而仅反映了故事板上的占位符视图。
After launching and dismissing the modal VC, the textview does adopt to its content. 在启动和关闭模式VC之后,textview确实采用了其内容。
As far as I know there is nothing that happens in the course of the 2ndVC launching that could change anything with the 1st. 据我所知,在第二次VC启动过程中没有发生任何事情可以改变第一次VC的情况。
My logs show ViewDidLoad is called by the first VC just once when it originally loads. 我的日志显示,最初加载时,第一个VC仅调用一次ViewDidLoad。 Viewwillappear is called by the first VC twice: when it originally loads and then after the 2nd VC is dismissed. Viewwillappear被第一个VC调用两次:最初加载时,然后关闭第二个VC之后。
Are there any methods other than view willappear that fire in a presenting VC when you dismiss a presented one? 当您关闭已呈现的VC时,除了view将出现以外,还有其他方法会触发该VC吗?
This is the code in VC1 to launch the 2nd VC. 这是VC1中用于启动第二个VC的代码。
UIStoryboard *storyBoard = self.storyboard;
IDEditListVC *editVC =
[storyBoard instantiateViewControllerWithIdentifier:@"editlist"];
editVC.list = _list;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController: editVC];
[self presentModalViewController:nav animated:YES];
//This is the code in VC1 viewWillAppear to obtain the height of text view. //这是VC1 viewWillAppear中的代码,用于获取文本视图的高度。 Result changes before and after launching and dismissing 2nd VC 启动和关闭第二个VC前后的结果更改
self.textView.text = listText;
float listHeight = self.textView.contentSize.height;
NSLog(@"listHeight%f",listHeight);
Try this 尝试这个
-(void)viewDidLayoutSubviews
{
self.textView.text = listText;
float listHeight = self.textView.contentSize.height;
NSLog(@"listHeight%f",listHeight);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.