ios-autolayout

What is the basic difference between Auto Layout and Auto Resizing in iOS

☆樱花仙子☆ 提交于 2019-12-03 12:12:56
问题 I have been searching the proper difference between Auto Layout and Auto Resizing, but didn't able to find the exact answer. Where I can use "Auto Layout" and where "Auto Resizing" in app? Any help would be a part of thanks. 回答1: As Matt Neuberg states in his book: Autoresizing is a matter of conceptually assigning a subview “springs and struts.” A spring can stretch; a strut can’t. Springs and struts can be assigned internally or externally. Thus you can specify (using internal springs and

In 7.3/9/2+ Swift how to disable rotation animation, when device rotates?

自闭症网瘾萝莉.ら 提交于 2019-12-03 10:16:26
This question is strictly about iOS9+ Say you have an ordinary modern app (autolayout, storyboard, universal) which does allow all four rotation positions you want it to autorotate in the normal way, so it will change to your new constraint-based layouts when user rotates device from landscape to portrait But you simply want NO animation during the user rotating the device. You want it to just "click" to the new sideways or upright layout. The only way I have been able to achieve this is by adding: override func viewWillTransitionToSize(size:CGSize, withTransitionCoordinator coordinator

How to solve: This application is modifying the autolayout engine from a background thread

雨燕双飞 提交于 2019-12-03 08:01:12
This error is logged to the console when some part of the code is changing UI items from other threads than the main thread. But how can I find where it does this? Main problem with "This application is modifying the autolayout engine from a background thread" is that it seem to be logged a long time after the actual problem occurs, this can make it very hard to troubleshoot. I managed to solve the issue by creating three symbolic breakpoints. Debug > Breakpoints > Create Symbolic Breakpoint... Breakpoint 1: Symbol: -[UIView setNeedsLayout] Condition: !(BOOL)[NSThread isMainThread] Breakpoint

Dynamically size Table View Cells using Auto Layout constraints

会有一股神秘感。 提交于 2019-12-03 05:08:48
问题 Update I have revised the question completely after my latest findings. Goal My goal is to implement the following effect: There is a simple table view The user selects a row The selected row expands, revealing another label below the original one Please note that I am aware, that this can be achieved by inserting/deleting cells below the selected one, I already have a successful implementation using that method. This time, I want to try to achieve this using Auto Layout constraints. Current

Autoresizing not working in iOS11 / XCode 9

自闭症网瘾萝莉.ら 提交于 2019-12-03 04:18:20
It appears that the Autoresizing of views is no longer reliably working when building for iOS11 with XCode 9. The layout of several views end up with the positioning of controls as they are in the XIB, but the appropriate resizing has not happened. This has been working fine in iOS10, and works with our old app running in iOS11. However, rebuilding the app the positioning and sizing fails. Has something changed that impacts the use of autoresizingmask ? Is there a way to automatically convert from AutoResizing to AutoLayout and Constraints ? Edit: The controls that are giving trouble are the

how to put constraints on views in interface builder to satisfy all iphone Screen in Xcode 8

情到浓时终转凉″ 提交于 2019-12-02 22:52:45
问题 I have been trying the following such as pinning, aspect ratio, vertical spacing ,horizontal/vertical spacing,leading/trailing space; but it is not working uniformly for all iPhone screen from iPhone se and above. 回答1: You dont apply constraints for each device anymore. You apply auto layout constraints per size class. If you are aware each and every iOS devices falls under one of the size class in each orientation. If you aren't aware of size class do read about it. As to answer your

Dynamically size Table View Cells using Auto Layout constraints

蓝咒 提交于 2019-12-02 18:24:52
Update I have revised the question completely after my latest findings. Goal My goal is to implement the following effect: There is a simple table view The user selects a row The selected row expands, revealing another label below the original one Please note that I am aware, that this can be achieved by inserting/deleting cells below the selected one, I already have a successful implementation using that method . This time, I want to try to achieve this using Auto Layout constraints. Current status I have a sample project available for anyone to check , and also opened an issue . To summarize

Make UICollectionViewCell's height match its content (sum height of all sub views) with AutoLayout

杀马特。学长 韩版系。学妹 提交于 2019-12-02 18:11:41
问题 I found the next answer to make UIView's height match its content https://stackoverflow.com/a/39527226/7767664 I tested it, it works fine (if UIView height size in storyboard bigger or smaller than its content then during runtime it autoresize itself to match the content). But if I use UICollectionViewCell instead of UIView then nothing changes, height of cell is never changed, it always has the hardcoded height we have in storyboard properties: What else can I do? Also I have 2 sections in

How to efficiently use Autolayut and Auto-Resizing in same target?

人走茶凉 提交于 2019-12-02 15:58:56
问题 I have one target. It's a login based application. Because of legacy code, I am forced to use Auto-Resizing in some View Controllers whereas I have updated newer UI using Auto-Layout. If the Autolayout has to work on iPhone 6 and 7 (4.7"/5.5" screens) I have to add the launch images for these. PROBLEM : All my screen that are not using auto layout gets disturbed when I add the Launch image. If I don't use the launch screen images, all the View that use auto layout are scaled up and appears

rightAnchor constraint did not apply when added programmatically - swift

♀尐吖头ヾ 提交于 2019-12-02 14:33:05
问题 When I Added rightAnchor constraint, constant= 20 did not apply. In leftAnchor is ok override init(frame: CGRect) { super.init(frame: frame) addSubview(collectionView) collectionView.translatesAutoresizingMaskIntoConstraints = false NSLayoutConstraint.activate([collectionView.leftAnchor.constraint(equalTo: leftAnchor, constant: 20), collectionView.topAnchor.constraint(equalTo: self.topAnchor), collectionView.rightAnchor.constraint(equalTo: rightAnchor, constant: 20), collectionView