Can I use setModalPresentationStyle on iPhone? - iphone

I've been watching some of the iPhone development videos off iTunes specifically "Standford Fall 2011 iPad and iPhone App Development" and in lecture 15 Modal View Controller/test/Animation is says that setModalPresentationStyle is only to be used with iPad. I was wanting to do this with an iPhone app, is this possible? has there been an update since this was made that allows it? or is there another way I can simulate the features in this? Like the form sheet presentation style.

Indeed, the modalPresentationStyle property of a view controller only applies to iPad. On iPhone and iPod touch, the presentation style is always fullscreen.
According to the documentation:
The presentation style determines how a modally presented view
controller is displayed on the screen. On iPhone and iPod touch
devices, modal view controllers are always presented full-screen, but
on iPad devices there are several different presentation options. For
a list of possible presentation styles, and their compatibility with
the available transition styles, see the “UIModalPresentationStyle”
constant descriptions.
To get the same effect as a form sheet presentation on the iphone, the easiest is to present a modal view controller setting it's modalTransitionStyle set to UIModalTransitionStyleCoverVertical (which is the default transition style).

On iPhone and iPod touch, modal view controllers are always presented full-screen, but on iPad there are several different presentation options.
https://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html

You can try custom open source library for presenting form sheet on iPhone https://github.com/m1entus/MZFormSheetController

Related

Is there a way to prevent modal view to take fullscreen on iPhone

I know this is an iPhone thing that the ViewController will take fullscreen when presented modally (in iPad it has transparent layer and not fullscreen). But is there a possible way to prevent the ViewController getting fullscreen on iPhone? I found some third party libraries that claim to do it but I'm hoping there's a way to do it without a third party library.
You might create a controller with a clear background then add a view on top that is sized however you like:
iOS: Modal ViewController with transparent background

How do I add full screen iAd's on iPhone?

When a user clicks a button, I want a full screen iAd to appear, before the user can continue.
I can create the popup view, but how do I fill the whole view with an iAd? (e.g. like its done in wordfeud)
ADInterstitialAd (or full screen iAd) is only available for the iPad. You can't use it on the iPhone.
From iAd Programming Guide:
Full-Screen Advertisements are Only Available on iPad
Have a look at that guide to see how to implement full-screen iAds on the iPad.
Use the ADInterstitialAd class. You can present it from another view controller (e.g. your main game board’s) with -presentFromViewController:, or within an existing view with -presentInView:.

iOS Bubble Popup Menu similar to ITunes

Could anyone provide some guidance on how to implement that speech-bubble like popup menu when you click "More" in the IPhone IPod application toolbar?
I think you are looking for UIPopoverController. Popover controllers are just containers for view controllers: write a view controller that does what you want, and you're set. But this is for iPad. If you want this for iPhone, then read on. I have put up some solutions.
You could even explore UIActionSheet but UIPopOverController gives more flexibility.
I believe you are talking about something like this ?
Here are some solutions you could adopt -
Forgot that you wanted this for iPhone, Have a look at the iPhone UIPopoverController implementation: WEPopover
On iPhone you would generally use a UIActionSheet for a stack of buttons like that. It slides up from the bottom, rather than popping up next to the button, but that's the standard behavior on iPhone.
Or you could manually instantiate a UIView using a custom background image or drawing with transparency, add some UIButtons (or other type of custom view) on top, and also somehow handle all touches outside that view.
Note that is is non-standard UI. An actionsheet would be more HIG compliant.

UISplitViewController for iphone

I want to create an iPhone (not iPad) app with a split screen view that shows two view controllers on the same screen, one on the left and one on the right of the screen (landscape only).
Is there a way to make UISplitViewController work for iPhone, or is there an open source library i can use to achieve this look?
As said, you can not use a split view controller. However, I dont think you need it anyway. Its a little cumbersome and restrictive.
You can achieve the effect of the split view controller easily using subviews. (Try to avoid using multiple view controllers as this is generally bad practice).
Create two custom views and ad them as sub views to the main view. Look at their auto resizing properties. Try to use interface builder. Show / hide you side view when the user rotates.
UISplitViewControllers aren't that useful - you can mimic their effectes easily.
There is no way you can achieve this using the UISplitViewController class. If you take a look at the Apple reference documents it clearly states that the UISplitViewController is an iPad-specific viewcontroller.
Note this point
If you are developing a universal application, though, be sure not to create and use these controllers when your application is running on an iPhone or iPod touch.

presentModalViewController for UIImagePicker fails in landscape mode for iPhone 3.0

First of all, my code isn't complex - in fact it's just two sample programs from "Beginning iPhone Development: Exploring the iPhone SDK", combined into one program. I took the ViewSwitcher application, which switches between a blue view and a yellow view, and replaced the YellowViewController with the CameraViewController from the camera application.
I have three ViewControllers total. SwitchViewController just switches between BlueViewController and CameraViewController.
Inside CameraViewController, I'm trying to use a UIImagePickerController to choose an image. The picker is presented with presentModalViewController. The catch is that I want to do this in landscape orientation.
Everything works fine under 2.2.1, and everything works fine in 3.0 in portrait mode.
In 3.0 under landscape orientation, however, things break. If I set SwitchViewController to landscape orientation, my screen goes white when I try to present the picker. If I rotate the iPhone a few times, I can see a corner of the picker, which apparently was displayed off screen.
If I set CameraViewController to landscape orientation, the picker doesn't come up at all.
I think this page may have a clue when it says "The most prominent change [in 3.0] I can see is that the modal view controller will always use the application frame instead of the parent view controller's frame." I don't understand exactly what that means, though.
Any help is greatly appreciated. Thanks!
I believe what that means is this: Modal views always use the full screen, even if the parent view controller that invokes them controls a view that is only part of the screen. This makes sense for standard modal views like the camera picker, but I can see why someone who creates a custom modal view might want it to be smaller.
Not sure if that really helps solve your problem though.
Question -- what happens if you bring up the modal view and THEN rotate the phone?
You must have used addSubview in your parent view controller, try using presentModalViewController:.