UIScreen MainScreen Bounds returning wrong size

前端 未结 6 2044
半阙折子戏
半阙折子戏 2020-11-29 04:10

So I created a new project with the latest version of XCode and tried to log the screen size of my app (to determine the device type for UI). I ran the following code from m

6条回答
  •  粉色の甜心
    2020-11-29 04:55

    I faced this problem when opening an old project. So, I found the solution. In my case, the problem is that I don't have LaunchScreen file and information in info.plist file about this.

    1. Right-lick on your info.plist -> Open As -> Source Code
    2. Add this two lines between and

      UILaunchStoryboardName LaunchScreen

    The body of info.plist file if it needed:

        
    
    
    
        CFBundleDevelopmentRegion
        $(DEVELOPMENT_LANGUAGE)
        CFBundleExecutable
        $(EXECUTABLE_NAME)
        CFBundleIdentifier
        $(PRODUCT_BUNDLE_IDENTIFIER)
        CFBundleInfoDictionaryVersion
        6.0
        CFBundleName
        $(PRODUCT_NAME)
        CFBundlePackageType
        APPL
        CFBundleShortVersionString
        1.0
        CFBundleVersion
        1
        LSRequiresIPhoneOS
        
        UILaunchStoryboardName
        LaunchScreen
        UIRequiredDeviceCapabilities
        
            armv7
        
        UISupportedInterfaceOrientations
        
            UIInterfaceOrientationPortrait
        
        UISupportedInterfaceOrientations~ipad
        
            UIInterfaceOrientationPortrait
            UIInterfaceOrientationPortraitUpsideDown
            UIInterfaceOrientationLandscapeLeft
            UIInterfaceOrientationLandscapeRight
        
    
    
    

    I hope, It will help!

提交回复
热议问题