6 Replies
      Latest reply on Aug 11, 2015 2:11 AM by oscahie
      Tweak Level 1 Level 1 (10 points)

        Hi,

         

        i need in my App following Code:

        - (NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskPortrait;
        
        }
        
        

         

        this works fine in iOS 8.

         

        but in iOS 9 (Xcode 7) i became a warning:

        "Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' (aka 'enum UIInterfaceOrientationMask') vs 'NSUInteger' (aka 'unsigned long')"

         

        i have changed it to:

        -(UIInterfaceOrientationMask)supportedInterfaceOrientations{
            return UIInterfaceOrientationMaskPortrait;
        }
        
        


        and have fixed this Warning. But now i became a Warning in Xcode 6.3 (iOS 8)

         

        How can i make this Code compatible for iOS 9 AND iOS 7 / 8 ?

         

         

        Thanks, Tweak

        • Re: supported InterfaceOrientations iOS 8 vs. iOS 9
          KMT Level 9 Level 9 (15,255 points)

          The typical way to bifurcate based on iOS version is via idioms.

          Example is for Swift:

          to detect iOS version

          struct Version{ static let SYS_VERSION_FLOAT = (UIDevice.currentDevice().systemVersion as NSString).floatValue static let iOS7 = (Version.SYS_VERSION_FLOAT < 8.0 && Version.SYS_VERSION_FLOAT >= 7.0) static let iOS8 = (Version.SYS_VERSION_FLOAT >= 8.0 && Version.SYS_VERSION_FLOAT < 9.0) static let iOS9 = (Version.SYS_VERSION_FLOAT >= 9.0 && Version.SYS_VERSION_FLOAT < 10.0) }

          how to use

          if Version.iOS8 { println("iOS8") }

          • Re: supported InterfaceOrientations iOS 8 vs. iOS 9
            Rincewind Apple Staff Apple Staff (290 points)

            I don't think there is a way in Swift for you to support both from a compilation stand point. Just like with other changes for Swift 2, Xcode 7, and iOS 9, I would recommend you make these changes on a branch in your code repository such that it won't interfere with your changes when working with Swift 1.2, Xcode 6.3 and iOS 8.3.

              • Re: supported InterfaceOrientations iOS 8 vs. iOS 9
                Tweak Level 1 Level 1 (10 points)

                i use Objective-C and don't know, how can i make the code available for iOS9 and iOS 8. the "old" code does not run under iOS 9 and the new dont rund under iOS 8... iam not professional and need a idea :-)

                  • Re: supported InterfaceOrientations iOS 8 vs. iOS 9
                    junkpile Level 6 Level 6 (2,485 points)

                    I think you are misunderstanding. The old code will run fine under iOS 8 or 9, and the new code will also run fine under iOS 8 or 9.

                     

                    The old syntax won't *compile* when built using Xcode 7 and the iOS 9 *SDK*. Likewise the new syntax won't *compile* using Xcode 6 and the iOS 8 SDK. But a binary built using either tool will run on whatever OS it's targeted for.

                     

                    If you're not planning to release until this fall, after Xcode 7 / iOS 9 goes public, then just use the new syntax and Xcode 7 and don't worry about it. If you need to release sooner, use Xcode 6 and the old syntax and don't worry about it. There's not much point trying to make code that compiles under either. You'd need some conditional compilation directives and it would get messy. Better to just use a branch, as Rincewind suggested, if you absolutely have to have code that compiles against both SDK versions.

                • Re: supported InterfaceOrientations iOS 8 vs. iOS 9
                  jacky.li.1981 Level 1 Level 1 (0 points)

                  just use this one:

                   

                  #pragma clang diagnostic push

                  #pragma clang diagnostic ignored "-Woverriding-method-mismatch"

                  #pragma clang diagnostic ignored "-Wmismatched-return-types"

                  - (UIInterfaceOrientationMask)supportedInterfaceOrientations

                  #pragma clang diagnostic pop