質問

I have viewController with two buttons

button 1:

set prompt text and heeds when navbar resizes for prompt - add subview to him

button 2:

show next viewcontroller, and on that viewcontroller does not set prompt text.

And navbar resizes, but still has subview.

i can manually remove custom view, but i want do this only when navbar resizes to normal size without prompt.

As u can see on image below

enter image description here

Navbar resizes, and back arrow on custom view - here i want hide custom view.

役に立ちましたか?

解決

put this code inside your MainViewController.m after MainViewController @implementation and before @end

- (void)viewDidLayoutSubviews{

    if ([self respondsToSelector:@selector(topLayoutGuide)]) // iOS 7 or above
    {
        CGFloat top = self.topLayoutGuide.length;
        if(self.webView.frame.origin.y == 0){
            // We only want to do this once, or if the view has somehow been "restored" by other code.
            self.webView.frame = CGRectMake(self.webView.frame.origin.x, self.webView.frame.origin.y + top, self.webView.frame.size.width, self.webView.frame.size.height - top);
        }
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top