7 Replies
      Latest reply on Feb 6, 2020 2:36 PM by gbenna
      gbenna Level 1 Level 1 (0 points)

        I have an app that I am updating since Apple made having a launch screen storyboard a must.  I have created the launchscreen storyboard and included all the launch images in my images.xcassets folder.

        The problem is that when the simulator loads the app in iPhone 8, 8+, iPad (7gen),iPad Air, iPad 9.7 the launch image is blank.  The included images do not load.  In the simulators for the iPhone 11, 11Pro, 11ProMax, iPad11, and iPad12.9 the launch images show up fine.

        I know the correct phone is being loaded because I have put:

         

                if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){

                      NSLog(@"THIS IS DEVICE STRING ");

         

               if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 480.0){

                   // 4 320x480 x0 y0

               deviceString2 = @"0";

                   NSLog(@"THIS IS DEVICE STRING -0");

                    }

                    else if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 568.0){

                        //5 320x568 x0 y*1.183+62

                       deviceString2 = @"0";

                        NSLog(@"THIS IS DEVICE STRING 0");

                     }

                    else if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 667.0){

                        //678 375x667 x*1.171, y*1.389+25

                        deviceString2 = @"1";

                        NSLog(@"THIS IS DEVICE STRING 1");

                     }

                    else if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 736.0){

                    //678+ 414x736 x*1.29, y*1.53+28

                        deviceString2 = @"2";         

                        NSLog(@"THIS IS DEVICE STRING 2");

                      }

                   else if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 812.0){

                           //11pro&max 375x812 x*1.17, y*1.69+97

                        deviceString2 = @"3";           

                         NSLog(@"THIS IS DEVICE STRING 3");

                    }

                    else if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 896.0){

                                //11 414x896 x*1.29, y*1.867+107

                       deviceString2 = @"4";            

                       NSLog(@"THIS IS DEVICE STRING 4");

                   }}

           else if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){

         

               [advertise setTitle:NSLocalizedString(@"CHESSOBJ1",nil) forState:UIControlStateNormal];

                 if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 1024.0){

                     //9.7 768x1024 x*2.4 y*2.13-122

                               deviceString2 = @"5";

                     NSLog(@"THIS IS DEVICE STRING 5");

                               }

                     else if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 1080.0){

                         //7gen 810x1080 x*2.53 y*2.256-128

                              deviceString2 = @"6";

                               NSLog(@"THIS IS DEVICE STRING 6");

                             }

                     else if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 1112.0){

                         //10.5 834x1112 x*2.6 y*2.32-130

                               deviceString2 = @"7";                   

                                NSLog(@"THIS IS DEVICE STRING 7");

                                    }

                     else if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 1366.0){

                         //12.9 1024x1366 x*3.2 y*2.85-162

                                 deviceString2 = @"8";

                               NSLog(@"THIS IS DEVICE STRING 8");

                                    }

                      else if([UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height == 1194.0){

                         //11 834x1194 x*2.6 y*2.49-89

                                 deviceString2 = @"9";

                              NSLog(@"THIS IS DEVICE STRING 9");

                                    } }

        On the simulators the correct log is written for the device loaded, but still no images show up.

        On the iPhone six the log says that the iPhone 6 is an iPhone 5 in size. (I'm not sure if the iPhone 7,8,6+,7+,8+ do the same since I am not rich enough to own all devices.  I have read about this but I need to have the app recognize each iPhone so I can designate the placement and size of my various objects in the space.  I cannot use storyboard auto resize as this doesn't work.  The app I have connects two Apple devices together through bluetooth to play games together.  When I move a piece on my device it moves on your device.  So precise placement on various devices is essential.

        HOW CAN I GET THE APP TO RECOGNIZE THE VARIOUS DEVICE SIZES THROUGH CODE?

        I can't believe Apple would take this ability away form a developer.

        Please Help!

        • Re: launch screen images not loading
          Claude31 Level 8 Level 8 (8,115 points)

          The problem is that when the simulator loads the app in iPhone 8, 8+, iPad (7gen),iPad Air, iPad 9.7 the launch image is blank.  The included images do not load.  In the simulators for the iPhone 11, 11Pro, 11ProMax, iPad11, and iPad12.9 the launch images show up fine.

          HOW CAN I GET THE APP TO RECOGNIZE THE VARIOUS DEVICE SIZES THROUGH CODE?

           

          What is your problem exactly ?

               Launch image does not load ?

               Launch image is not the right size ?

           

          But when launch image shows, app is not loaded, so you will not be able to adapt size programmatically

          But you can set constraints in IB (like equal width to its superview).

          Once you have done, remove the app from device or from simulator, to flush the cache.

            • Re: launch screen images not loading
              gbenna Level 1 Level 1 (0 points)

              I guess I don't care about the launch images loading only in relation to the getting the correct screen size to load.

              Let me explain what I am trying to do and why.  Then you can tell me if it is a problem or I can use autoresize.

              Like I said my app connects two devices by bluetooth and lets those two players play games with each other.

              For example we are playing a game of checkers.  When I move the piece on my screen from my side (closer to the bottom) toward the top (your side) the piece on your device should move from the top (side away from you) toward the bottom (your side).  This makes it look like we are sitting in front of the same board across from each other.  For this to happen the distance I move the piece up (from bigger to smaller coordinate on my screen) the piece has to move down (smaller to larger coordinate on your screen). But that coordinate has to be related proportionally to the screen size.

              To do this I based everything on the 320 x 480 screen.  The board is place and sized to fill the screen side to side, is square and is centered top to bottom.  if the player is using an iphone 5 the board width is the same 320 but the height is 568 instead of 480.  So to center the board I subtract the 480 from the 568 (88) and divide that by two.  I add 44 to the placement of all objects to center them top to bottom.  The same applies to an iPhone 6 which is 375 x 667.  I find that 375 is 1.183 times bigger than 320 so I take the width and height time 1.183 (375x567) so I have to add 50 to all elements to move them to the center. 

              Now when I move the piece I have increased its travel distance to the new screen size and if I sent that over to the other device it would move only that distance.  To compensate for this I subtract the added distance and divide by the same multiplication figure, returning it to a 320x480 screen. 

              When the other device receives the pieces coordinates they are adjusted by that devices multiplication factor and addition number and subtracted from the width and height so the piece that is moving up on the right of my screen is now moving down and on the left on your screen, with the appropriate size and placement adjustments.  If this can be done with autoresize please point me to a tutorial that will show me how.  I just don't understand why Apple took that ability to write code for different devices away from developer.

                • Re: launch screen images not loading
                  Claude31 Level 8 Level 8 (8,115 points)

                  I guess I don't care about the launch images loading only in relation to the getting the correct screen size to load.

                  So, the title of your post is really misleading.

                   

                  Do you speak of the launch screen or of the main view ?

                  Launch screen is displayed only temporarily, so will not be used during the game.

                   

                  To do this I based everything on the 320 x 480 screen.  The board is place and sized to fill the screen side to side, is square and is centered top to bottom.  if the player is using an iphone 5 the board width is the same 320 but the height is 568 instead of 480.  So to center the board I subtract the 480 from the 568 (88) and divide that by two.  I add 44 to the placement of all objects to center them top to bottom.  The same applies to an iPhone 6 which is 375 x 667.  I find that 375 is 1.183 times bigger than 320 so I take the width and height time 1.183 (375x567) so I have to add 50 to all elements to move them to the center.

                   

                  Why doing so ? You should just center vertically in safeArea.

                   

                  When the other device receives the pieces coordinates they are adjusted by that devices multiplication factor and addition number and subtracted from the width and height so the piece that is moving up on the right of my screen is now moving down and on the left on your screen, with the appropriate size and placement adjustments.  If this can be done with autoresize please point me to a tutorial that will show me how.

                   

                  That' a different point: you want now the 2 players to see the board from a different side.

                  The best would be:

                  define a class Board, each player will have a board instance:

                  - define an absolute board (320*480)

                  - define a boradAsSeen, which size is adapted to the player's screen

                  - define a propert seenFromTop: Bool: will be true for blacks and false for whites

                   

                  - Echange only absolute positions

                  - when moving, compute the equivalent absolute move

                  - When display, make the conversion from absolute board to the right size and orientation

                   

                  I just don't understand why Apple took that ability to write code for different devices away from developer.

                  That's not the problem. You uust have to build the right data models.

                   

                  Hope that helps.

                    • Re: launch screen images not loading
                      gbenna Level 1 Level 1 (0 points)

                      This seems to be a lot more work since I have everything put together the way I had it. But if there is no other way.

                      Can you tell me though why when I run the code I have in Simulator and I choos iPhone 8, or iPhone 8+  it is recognized as a 667 size height screen an show by log it is running on that size screen.  But when I run it on the iPhone 6 which has the same size height screen as the iPhone 8 the log says it is running on a 568 iPhone 5 size screen.  Why does it work on Simulator and not on phone?  Is there something wrong with my phone, is this a glitch in the xcode program.  Or is Apple not letting you check the size of the phone screen and write code for it.  I just want to know why it runs ok on Simulator but not on my iPhone 6.   Thank you for all your help. 

                        • Re: launch screen images not loading
                          Claude31 Level 8 Level 8 (8,115 points)

                          Could you show the code where you get the screen size.

                           

                          Read this:

                          https://stackoverflow.com/questions/21668497/uiscreen-mainscreen-bounds-returning-wrong-size

                           

                          It says that size is computed from the some data in your xcassets.

                          If you miss some, it will be miscomputed !

                          But does this still occur with launch storyboards ?

                           

                          Check also your assets catalog to see if it is complete for all icons size ?

                           

                          May read also

                          https://stackoverflow.com/questions/38773513/uiscreen-mainscreen-bounds-give-wrong-size/38784001

                           

                          Hope that helps.

                            • Re: launch screen images not loading
                              gbenna Level 1 Level 1 (0 points)

                              I am using a Launch Screen. storyboard with LaunchImages in my Images.xcassets folder.  I have all of my icons and all the LaunchImages of the correct size included.  I had for portrait and landscape.  When I launched iPhone 8 and iPhone 8+ in Simulator the launch images do not show up for the breif time before the app launches main page.  The text shows up at the correct place and size but not the image.  I have stated this at the beginning of my post.

                              The problem is that when the simulator loads the app in iPhone 8, 8+, iPad (7gen),iPad Air, iPad 9.7 the launch image is blank.  The included images do not load.  In the simulators for the iPhone 11, 11Pro, 11ProMax, iPad11, and iPad12.9 the launch images show up fine. The text show up so the launch screen is loading.  On my iPhone 6 the launch image does not load but the text does. 

                              On the Simulator when I ask what size height screen is loading  on all screens the correct log shows the requested size screen is loading.  However on my iPhone 6 the log says that the iPhone 6 screen size height is 568 which is an iPhone 5. 

                              As I said all the launch Images are in my images.xcassets folder in LaunchImages.  Some load some don't in the Simulator.  But the correct screen size is always recognized.

                              On my iPhone 6 no launch Image and the wrong size screen is loaded.

                              WHY

                                • Re: launch screen images not loading
                                  gbenna Level 1 Level 1 (0 points)

                                  So I used the idea of having everything relate to the center of the screen and that helps to simplify the coding but it doesn't really help with the different screen sizes with respect to sending and interpolating the players on the screen.  Through some research and trial and error I have discovered that Apple has made the 667 screen on the iPhone 6 (not sure about the 7) into 568.  Using this information I am able to get things to work ok.  I am going to borrow friends and family phones to check out other sizes and see how they work.  My last question which is related is WHAT SIZE HAS APPLE DESIGNATED FOR THE IPHONE 6+.  Since the iPhone 6 is the iPhone 5 size.  What is the iPhone 6+s size.  Does anyone know?  Thanks