How to split Code for iOS 3.0 and iOS 3.2 so I can use MPMoviePlayerViewController if OS 3.2++

前端 未结 2 2081
悲哀的现实
悲哀的现实 2020-12-17 06:00

I have a video that I play. To use full screen in iOS 3.2 I use the MPMoviePlayerViewController (seems to only work with that Class). But if I want to build for iOS 3.0 I ob

2条回答
  •  悲哀的现实
    2020-12-17 06:31

    I'm not sure if this is what you are trying to do, but as per Apple's recommendation for universal apps in the iPad Programming Guide, if you want to build for multiple OS versions with inconsistent APIs, you should use NSClassFromString, and go from there. This way, you only have to have one target (the lowest OS you support) and through out your code have things like

    Class mplayerControllerClass = NSClassFromString(@"MPMoviePlayerViewController");
    if(mplayerControllerClass != nil) {
       //Code for 3.2, e.g. [mplayerControllerClass alloc]
    } else {
       //Code for pre-3.2 OSes
    }
    

提交回复
热议问题