How can I fix the “UIPopoverController is deprecated” warning?

后端 未结 4 707
一向
一向 2020-12-01 01:19

I am using this code:

mediaLibraryPopover = [[UIPopoverController alloc] 
                        initWithContentViewController:avc];
[self.mediaLibraryPopov         


        
4条回答
  •  感情败类
    2020-12-01 02:01

    EDIT: Regarding the down-votes. First a fun and relevant story:

    http://www.folklore.org/StoryView.py?story=Negative_2000_Lines_Of_Code.txt

    I posted the answer below in order to help coders that might have been stuck in the mindset that iPad/iPhone still needed separate execution paths when presenting a media picker UI. At the time of my original post this was not clear in the other answers. This solution path simplified my code and the future maintenance of my App. I think others might find this perspective useful because sometimes removing the right lines of code can be a good solution.

    End of edit.

    If you already have a working program and just want to get rid of the depreciation warning this could work for you.

    In my code, and in my understanding, Popovers were introduced for the iPad and are iPad specific. Apple seems to have changed that. So, if you already have a working program that uses something like this:

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        // use popovers 
    else
        //  don't use popovers
    

    what you can do is just get rid of the iPad specific code (which is probably the code using Popovers) and have your program run the same instructions for both iPhone and iPad. This worked for me.

提交回复
热议问题