autolayout

How to fix strange NSLayoutConstraint errors that don't seem to effect layout in custom UITableViewCell

醉酒当歌 提交于 2019-12-22 06:35:13
问题 Each time one of my custom UITableViewCells is drawn by tableView:cellForRowAtIndexPath: The console spits out a bunch of NSLayoutConstraint inconsistencies. I understand most of these: Unable to simultaneously satisfy constraints. ...boring stuff.. "<NSLayoutConstraint:0x8b0eb60 V:|-(NSSpace(20))-[UILabel:0x8b0cb30] (Names: '|':UITableViewCellContentView:0x8bd7d40 )>", "<NSLayoutConstraint:0x8b0db70 V:[UILabel:0x8b0cb30]-(NSSpace(8))-[UITextView:0x91dba00]>", "<NSLayoutConstraint:0x8b0dba0 V

Set UITableView's rowHeight to UITableViewAutomaticDimension in storyboard?

故事扮演 提交于 2019-12-22 05:57:09
问题 When creating an app for iOS 8 in Xcode 6, how do I set my UITableView's rowHeight to UITableViewAutomaticDimension ? In WWDC 2014 Session 226 "What’s New in Table and Collection Views", the speaker says that UITableViewAutomaticDimension is the new default value for programmatically created table views' rowHeight . However, he also mention that at the time of the session this is not the case for table views loaded from a xib/storyboard. Now that Xcode 6 GM is out, how do I set this value in

Launch Screen XIB: Missing Width / Height Constraints (Xcode 6)

时光总嘲笑我的痴心妄想 提交于 2019-12-22 05:50:47
问题 Using Xcode 6 , I am building an iOS app that targets iOS8 . I'm working on a LaunchScreen.xib file, created from the menu: File > New > File > iOS - User Interface - Launch Screen . "Use Auto Layout" is enabled. Inside the XIB's main UIView , I've placed a UIImageView . I would like to add width and height constraints, so that the UIImageView has the same size as the container. However, Xcode doesn't let me do that: I can only work with spacing and alignment. Here's what I see: What am I

Why is AutoLayout not taking care of my UICollectionView

牧云@^-^@ 提交于 2019-12-22 05:46:06
问题 I have built a very simple sample of an app (Source code on github) using a UICollectionView . Everything is working fine, as long as the app is in portrait mode. When it is changed to landscape mode however, the content cell is not resized appropriately, and thus, nothing is displayed. I thought that all the necessary AutoLayout constraints are in place. I am aware that I can implement collectionView:layout:sizeForItemAtIndexPath: , but my goal is to use AutoLayout as much as possible

my UIViews muck-up when I combine UIPanGestureRecognizer and autolayout

烈酒焚心 提交于 2019-12-22 05:33:33
问题 I’d like a ball to track my finger as I drag it along a circular trajectory for every allowable device orientation on iPhone or iPad. Views appear to be correctly centred when a device is rotated but the ball will not stay on the circumference and seems to go anywhere when I drag it. EDIT Martin R's answer now displays this as required. My only additional code change was to remove an unnecessary declaration var shapeLayer = CAShapeLayer() The maths in this example made perfect sense until I

Auto Layout: Y Position as the Max of Two Values

﹥>﹥吖頭↗ 提交于 2019-12-22 05:16:20
问题 I have a button playButton and to UIViews, myView1 and myView2, whose positions may change during execution. I want the top of playButton to be 10 units below the bottom of UIView1 OR the bottom of UIView2, whichever is the larger value (further down) . How would I express this using auto layout in code? I tried setting one constraint as greater or equal but it seemed to have no effect. 回答1: Here's one way to think about it: create a constraint that the top of playButton is greater than or

Auto Layout: Y Position as the Max of Two Values

社会主义新天地 提交于 2019-12-22 05:16:07
问题 I have a button playButton and to UIViews, myView1 and myView2, whose positions may change during execution. I want the top of playButton to be 10 units below the bottom of UIView1 OR the bottom of UIView2, whichever is the larger value (further down) . How would I express this using auto layout in code? I tried setting one constraint as greater or equal but it seemed to have no effect. 回答1: Here's one way to think about it: create a constraint that the top of playButton is greater than or

How to hide UITableViewCells while not violating AutoLayout constraints

非 Y 不嫁゛ 提交于 2019-12-22 04:56:47
问题 I'm currently working on an app to learn iOS programming and Swift. I have a view which contains two main subviews, a MKMapView and a UITableView. When a certain annotation is selected in the MapView, I want certain cells in the TableView to be hidden. If the annotation is deselected the cells should reappear. Currently I do this by setting the height for the cells to be hidden to 0 and calling tableView.beginUpdates() tableView.endUpdates() , however this causes all kinds of AutoLayout

iOS7 issues with NSIBPrototypingLayoutConstraint autolayout constraints generated by Interface Builder

淺唱寂寞╮ 提交于 2019-12-22 03:58:52
问题 Previously in iOS6, my chat message view controller displayed and animated correctly with carefully constructed autolayout constraints in IB. Here's the current view hierarchy with the constraints removed in Xcode 5: After upgrading to XCode 5 and iOS7, I found I needed to clear all the old constraints in order to account for the default translucent status bar, otherwise my toolbar would fall under the status bar. This happened despite calling setEdgesForExtendedLayout: with UIRectEdgeNone. I

UIView-Encapsulated-Layout-Height and Container View

孤街醉人 提交于 2019-12-22 03:43:57
问题 I have UIViewController 1 , that has scroll view . Inside this scrollview there is container view that pinned to top/bottom leading/trailing (without fixed height). Container view has UITableView pinned to top/bottom trailing/leading and height constraint with 0 constant , that will change in updateViewConstraints to content size height. When View of UIViewController 1 appears, Container View has constraint: NSLayoutConstraint:0x7b03e5f0 V:[UITableView:0x7c42a200(54)], NSLayoutConstraint