0

I have added a 'Help' button onto my map view as shown below.

enter image description here

When I open it in the simulator in (iPhone 7 mode) the button appears and performs a segue properly. I changed the operating iOS to 9.3 and tested it on a real iPhone 6 running 9.3 and the button functioned properly. However, I have tested it on a real iPhone 6 running 10.0 and the button does not appear.

I thought this could be to do with auto layout but it appears fine in storyboard, simulator and the real device.

I have attached a photo of my constraints for the button below. Constraints

Any thoughts?

T. Kearsley
  • 197
  • 3
  • 18

2 Answers2

0

This may not solve your immediate problem, but you should apply as many constraints to satisfy the auto layout engine and no more. Adding more constraints may not cause conflicts on devices of the same size, but will cause conflicts on devices of different sizes causing the layout engine to have to make decisions about which to break. Often it makes choices that you wouldn't. You can check your console to see if the layout engine is breaking constraints.

If you want the button in the bottom-right corner, you only need two constraints: trailing and bottom. UIButton's have an intrinsic content size, so if you have a static title, you do not need to worry about width or height. You should remove your other constraints.

beyowulf
  • 15,101
  • 2
  • 34
  • 40
0

You can delete all the constraints and use only 20 to the bottom and 20 to the right (trailing) to place it nicely there.

You can play with the numbers but the main idea is that you don't need to over complicate it with too many constraints.

i6x86
  • 1,557
  • 6
  • 23
  • 42
  • I've changed the constraints to as you said but still not working. I realised there is an error in the console when the button is clicked on saying **bjc[2303]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/....../AssetsLibraryServices (0x11ecf2998) and /Applications/Xcode.app/..../PhotoLibraryServices (0x11eb14880). One of the two will be used. Which one is undefined.** – T. Kearsley Jan 15 '17 at 01:10
  • It does seem to run but what would be causing this error? – T. Kearsley Jan 15 '17 at 01:12
  • Did you deleted the old constraints? – i6x86 Jan 15 '17 at 01:14
  • @T.Kearsley does my answer works? If so you can safety ignore the output here is an explanation: http://stackoverflow.com/questions/39521667/class-plbuildversion-is-implemented-in-both-applications – i6x86 Jan 15 '17 at 01:21
  • @T.Kearsley of that worked for you, please accept one of the answers! Edit: sorry I just saw you did it. – i6x86 Jan 15 '17 at 01:35