简体   繁体   中英

iOS Swift stackview inside a scrollview with constraints

I'm still getting familiar with iOS and the use of constraints . Initally had my layout setup with some constraints . But I ran into an issue. When entering text, my text fields are covered by the keyboard. I found some Apple docs: Doc One , Doc Two stating I should use a scrollview in this case. It sounded easy enough but every time I put the content in the scrollview things go nuts. I've tried adjust my constraints in several ways, but nothing seems to help.

Anyone have any insight on what I'm missing? Thank you

Before adding the Scrollview 在此处输入图片说明

After adding the Scrollview 在此处输入图片说明

If you use a UITableView with static cells and make your view controller a subclass of `UITableViewController, you don't need to worry about the keyboard. The table view controller takes care of keeping the focussed text field visible above the keyboard:

tableview示范

I wrote no code for that demo. It's all done in the storyboard. Here's the storyboard outline:

故事板大纲

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM