UIView Not Resizing to fill iPhone 6 Window

2019-08-25 07:43发布

I have a UITableView in my .xib file. I have this password protected, by obscuring it with another UIView that has a UITextField. Once the password has been entered, I remove the UIView from the superview. However, I am running into an issue that the UIView is not covering up all of the UITableView on the 6 and 6 Plus. How can I go about doing this, given that the UIView is not the main view in the xib, and simply added? I use auto layout and told it to pin to leading and trailing, but it isn't working.

Screenshot

2条回答
够拽才男人
2楼-- · 2019-08-25 08:19

You also need to pin its top and bottom edges. If it's in the same view that contains the stuff that you want to obscure, then pin the edges to the edges of the obscured content. Really, though, the comment about using a modal dialog is spot on.

查看更多
爷的心禁止访问
3楼-- · 2019-08-25 08:30

I finally managed to solve this on my own. I already had told it to pin everything, so that rendered @NRitH answer as useless. I simply added

    [password setFrame:self.navigationController.view.bounds];

before adding the view as a subview, and it worked perfectly.

查看更多
登录 后发表回答