vandadnp / iOS-8-Swift-Programming-Cookbook

This is the GitHub repository of O'Reilly's iOS 8 Swift Programming Cookbook
1.34k stars 472 forks source link

Question on Presenting Popovers #4

Closed ghost closed 9 years ago

ghost commented 9 years ago

In Presenting Temporary Information on the Screen with Popovers from Chapter 1, I believe it is recipe 1.2, the book mentions that the popovers can be used on both iPads and iPhones. I checked my code and It looks like everything is the same as what you have in your repo (https://github.com/vandadnp/iOS-8-Swift-Programming-Cookbook/tree/master/chapter-basics/Presenting%20Temporary%20Information%20on%20the%20Screen%20with%20Popovers). The application does not have any errors and loads fine. When I click the plus to present the popover on an iPad it works perfectly but on an iPhone I get the following error: *\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController initWithContentViewController:] called when not running under UIUserInterfaceIdiomPad.'

Im still learning but when googling about that error it seems that this may be an iPad only feature. Just curious if this is true or if there is a way to make this work on an iPhone using out of the box swift code (i.e. no third party libraries)?

I thought I read something about a popoverPresentationController property in iOS8 that can do this but it seems like that would require many changes to the current code so not sure if that is the right way to go to make it work on an iPhone. Any information would be greatly appreciated.

vandadnp commented 9 years ago

in the early betas for iOS 8, apple allowed UIPopoverController to be used on iPhones but maybe that was a glitch in their shift to using Swift. later, they have disabled that.

short answer is that this is not available anymore on iPhone and you can use it only on iPad. Does that answer your question?

ghost commented 9 years ago

Ah ok, I was afraid that might be the answer. Yes that answers the question. Thanks for the quick reply and the awesome book.

vandadnp commented 9 years ago

thanks for taking the time to report this.

PJRadadiya commented 8 years ago

summer-Top You Are Right.Book is awesome.