autolayout

constrain view.bottom to superview.bottom not bottomLayoutGuide in storyboard

自古美人都是妖i 提交于 2019-12-29 04:43:08
问题 In interface builder it only gives me the option of constraining my sub view to the bottom layout guide, not the superview. Because I am sometimes using the controller as a child controller in a container controller setup, I really want to constraint to the superview bottom, not the bottom layout guide. 回答1: Select your TableView and go to Editor -> Pin . From there you have 4 options to pin to superview: Leading Space to Superview Trailing Space to Superview Top Space to Superview Bottom

Why viewdidlayoutsubviews call multiple times?

孤人 提交于 2019-12-29 03:36:19
问题 I'm developing iOS Universal App on Swift, using auto layout and support only portrait. I found UIViewController#viewdidlayoutsubviews called multiple times. Instead, viewDidLoad ONLY call once on starting up MyApp's UIViewController . Why viewdidlayoutsubviews call multiple times? Constraints on each UIView ( UIButtons , UITextFields , etc..) will perform in order? Any Information will be appreciated. 回答1: LoadView is only called one: when the view needs to be loaded. LayoutSubviews ,

How to prevent AutoLayout from resetting view frames?

白昼怎懂夜的黑 提交于 2019-12-29 02:00:10
问题 I have a view with AutoLayout and it works nicely with different screen sizes. There's one element on the screen though that moves around depending on user actions. Whenever I navigate down to a different screen then back to this view, this element gets reset to its original position. I understand why this happens but how can I prevent it? I do want it to be setup correctly initially but not after the first time. 回答1: If you're using Autolayout you should never use setFrame/setBounds because

Auto layout how to hide 1 view in a view with 3 equal width views

不问归期 提交于 2019-12-28 18:22:11
问题 Currently I have 3 views inside 1 view (which is pinned to leading edge and trailing edge of superview). The 3 views look like this currently: However, in some cases, I wish to hide the indigo view, but still keep the last 2 the same widths like so: How can I achieve this with autolayout? Or how can I achieve this using IBOutlets for constraints? 回答1: If the deployment target is iOS9 or later , it is recommended to use UIStackView as the enclosing view. Setting isHidden to true on any view

UITableViewCell bad performance with AutoLayout

家住魔仙堡 提交于 2019-12-28 08:08:50
问题 I'm somewhat stuck with this one… any help is very appreciated. I've already spent lots of time debugging this. I've got UITableView with data source provided by NSFetchedResultsController . In a separate view controller I insert new records to the CoreData using [NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:] , save the managed object context and dismiss that controller. Very standard stuff. The changes in managed object context are then received by

Xcode 6 beta 7: storyboard adds extra space on right and left sides

五迷三道 提交于 2019-12-28 08:07:24
问题 When I add subview to root ViewController's view, and with auto layout setup leadingSpace,trailingSpace,topSpace and bottomSpace to zero, there are appear some extra spaces on left and right sides (so if I print subview's frame its origin will be 16 and size less on 32 than should be). So actually we get that leading and trailing spaces are not zeros... As you can see on picture leading space - zero, but origin.x = 16 Earlier I wasn't working hard with auto layout, so my question is: Is it a

Unable to simultaneously satisfy constraints Warnings with AVPlayerViewController embedded in storyboard

独自空忆成欢 提交于 2019-12-28 05:56:07
问题 I'm trying to set up an AVPlayerViewController completely through storyboards by embedding in a separate View Controller. Steps: Create Single View Application in Xcode. Embed VC in navigation Controller. Add toolbar at the bottom.(pinned to superView (Leading, Trailing, Bottom Layout Guide, Height(44)). Add container View in parent View Controller.(pinned to superView (Leading, Trailing), Top Layout Guide, toolbar Top). Remove the default View Controller that comes with container view. Drag

Why calling setNeedsUpdateConstraints isn't needed for constraint changes or animations?

别等时光非礼了梦想. 提交于 2019-12-28 04:57:05
问题 Readings: From this answer: This is what the accepted answer suggests to animate your view changes: _addBannerDistanceFromBottomConstraint.constant = 0 UIView.animate(withDuration: 5) { self.view.layoutIfNeeded() } Why do we call layoutIfNeeded when we aren't changing the frames. We are changing the constraints, so (according to this other answer) shouldn't we instead be calling setNeedsUpdateConstraints ? Similarly this highly viewed answer says: If something changes later on that

How to add Equal Spacing and equal width for button in iOS Auto layout

不羁岁月 提交于 2019-12-27 19:14:43
问题 Am new to Auto layout constraints in Xcode. I have one Bottom View like UITabBar with 6 UIButtons . Without constraints I aligned those buttons with 5 space padding with each buttons and each buttons has 50 width. Now,I am trying to make it by using Auto layout to support all Screen sizes. In Storyboard constrains I set equal width for 6 buttons and I made 60 space between each buttons. I set first button 0 to leading space and I set the last button 0 to tail constraints. I want the buttons

How to add Equal Spacing and equal width for button in iOS Auto layout

北城余情 提交于 2019-12-27 19:14:39
问题 Am new to Auto layout constraints in Xcode. I have one Bottom View like UITabBar with 6 UIButtons . Without constraints I aligned those buttons with 5 space padding with each buttons and each buttons has 50 width. Now,I am trying to make it by using Auto layout to support all Screen sizes. In Storyboard constrains I set equal width for 6 buttons and I made 60 space between each buttons. I set first button 0 to leading space and I set the last button 0 to tail constraints. I want the buttons