-3

Started to test my game on various devices. Every device works well except iPhone 8 Plus. On any other device and the Simulator (even simulated iPhone 8 Plus) the button is visible, but on iPhone 8 Plus it's not. I don't have a clue why this is happening.

1st pic shows Simulator 8 Plus screen, 2nd pic shows device screen.

Here's the code:

proceedButton = [[SelectionButton alloc] initWithFrame:CGRectMake([[UIScreen mainScreen] bounds].size.width / 2.0 - 60.00, [[ScreenSize sharedSize] yValue] + 10.0 + [[ScreenSize sharedSize] gameFieldSize], 120.0, [[ScreenSize sharedSize] opButtonSize]) andText:NSLocalizedString(@"DONEKey", @"Done")];
[proceedButton addTarget:self action:@selector(createPlayer) forControlEvents:UIControlEventTouchUpInside];
[proceedButton addTarget:self action:@selector(changePathColor:) forControlEvents:UIControlEventTouchDown];
[self.view addSubview:proceedButton];

On Simulator

On device

jscs
  • 63,694
  • 13
  • 151
  • 195
Palindrome
  • 161
  • 2
  • 11
  • Why don't you work with auto layout? – LinusGeffarth Nov 24 '17 at 11:32
  • I started project almost 2 years ago and didn't use it then. Now I have 13K strings of code. I don't think it's a good idea to change that. You think that's the reason? But it works on Simulator. – Palindrome Nov 24 '17 at 11:57
  • 1
    did you print the frame values in both simulator and real device ? i think you have to add frame console within your question. – MAhipal Singh Nov 24 '17 at 12:18
  • V12, thanks for your comment. I found out that on device the height of the button ([[ScreenSize sharedSize] opButtonSize]) is equal to 0. That's really weird because it works right on any other Plus devices. The resolution is 1242 x 2208, right? So why this is happening then? – Palindrome Nov 24 '17 at 12:38

1 Answers1

0

Thanks to V12 who pointed me in right direction I found the reason of that matter.

The problem was in that

CGSize screenSize = [[UIScreen mainScreen] bounds].size;

and

CGSize screenSize = [[UIScreen mainScreen] nativeBounds].size;

are the two different things.

At first I didn't understand why it worked on Simulator and not worked on real device. But when I printed frame values for both device and Simulator, I realised that value for Simulator was equal to values of iPhones 6,7,8 and value for real iPhone 8 Plus was equal to 2201. So I always was getting wrong results.

This link helped a lot, especially some of the comments

jscs
  • 63,694
  • 13
  • 151
  • 195
Palindrome
  • 161
  • 2
  • 11