简体   繁体   English

iOS /自动版式:取消已演示的控制器后,更改为演示视图

[英]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.

相关问题 调用viewWillAppear时显示视图控制器的问题被解除 - Issue with calling viewWillAppear of presenting view controller when presented one is dismissed 呈现MFMessageComposeViewController然后将其关闭后,呈现视图无法正确显示 - Presenting view not appearing properly after MFMessageComposeViewController is presented and then dismissed 关闭UIPopoverController后呈现视图控制器 - Presenting a View Controller after a UIPopoverController is dismissed WKWebView 操作表在被解散后解散呈现视图控制器 - WKWebView action sheet dismisses the presenting view controller after being dismissed 检测何时关闭呈现的视图控制器 - Detect when a presented view controller is dismissed 模态显示/关闭视图控制器时通知? - Notification when view controller is presented modally/dismissed? iOS-从显示的视图控制器中呈现视图控制器会更改其高度 - iOS - Presenting a view controller from a presented view controller changes its height 如果我将应用程序移到后台然后在 iOS 中转到前台,则显示的视图控制器将被关闭 - Presented view controller gets dismissed if i move my application to background and then come to foreground in iOS 如何在没有用户能够看到呈现视图的情况下使用模态视图控制器启动iOS应用程序? - How to start an iOS app with a modal view controller already presented without the user being able to see the presenting view? 如果当前视图控制器发生更改,如何关闭模式视图控制器? - How can a modal view controller be dismissed if the presenting view controller is changed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM