iAD - adBannerView rotation - ios

In my iPad app that supports all the device orientation, I add an adBannerView to the main view.
So far so good. It works and the ad rotates as expected.
If I click on a particular ad this is visualized full-screen, and when I close it I get back to my app.
The problem is that if you rotate the device while you are visualizing the full-screen ad, this rotates correctly, but when you close it and come back to the app the view is not rotated.
How to solve this? Please help or I will destroy my iPad! ;-)

Basically, you want the
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
method to be called again...
To do that, when the user closes the iAd, simply execute:
UIViewController *correctOrientation = [[UIViewController alloc]init];
[self presentModalViewController:correctOrientation animated:NO];
[self dismissModalViewControllerAnimated:NO];

Related

Handling iAd banner clicked in my game

I successfully added an iAd banner to my game (which plays in landscape mode), however I'm lost as to how to handle the ad being pushed. When the banner ad is pushed the game continues in the background and the player dies. Is there code to pause the game when the banner ad is clicked and resume when the ad goes away? Also when the banner ad is clicked, the ad shows up in portrait mode. Can I keep the ad in landscape mode so it is in sync with my landscape game? I'm a newbie please bear with me thanks!
You need to become the banner's delegate.
In your header file, change the #interface line by adding <ADBannerViewDelegate>, or add , ADBannerViewDelegate inside the angle brackets if you already have some. In the code where you create your banner ad, add a line like this:
self.bannerAdView.delegate = self;
Or if you're using Storyboards or IB, connect the banner ad's delegate outlet to your controller.
Once that's all done, implement these methods:
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
if (!willLeave)
{
// pause your game here
}
return YES;
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
// unpause your game
}
If your entire game is landscape, I'd recommend that you set your app to only support landscape orientations. This is done in your target settings as described in this technical note. I think that this will restrict the ads to landscape, but I've only tested that on an iPad, so it may be different on the iPhone.

UIActionSheet messes up shaking detection (motionBegan: delegate) on iPad

In my App, I use a UIActionSheet (nothing fancy) and present it (standard) using showFromBarButtonItem: and dismissing it using it's delegate clickedButtonAtIndex:. All simple and nice. Also I use the motionBegan: to detect a shake to do various stuff.
My App runs fine on an iPhone.
But, on the iPad as soon as the actionSheet is presented (once) the motionBegan: stops working! Any shake of the device (simulator) does not register! Before the actionSheet presentation, all shakes where register fine. As soon as it is presented, it stops.
I added a [actionSheetNav resignFirstResponder]; in the actionSheet:clickedButtonAtIndex: delegate (if that was a problem) but with no effect.
Any ideas?
(I could post the code, but nothing works even if the 1st command of (each related) method is a NSLog & a return immediately after)
Found it!
I just had to add a
[self becomeFirstResponder];
after the
[actionSheetNav resignFirstResponder];
line in the actionSheet delegate
-(IBAction)actionSheet:(UIActionSheet *)sender clickedButtonAtIndex:(NSInteger)myButton

UIWebView: Media Player Rotates View Controller

I'm encountering an issue while using a webview. My app is currently a portrait application, but when a media player loads in a webview within my app, the user can rotate the player, which rotates my view controller as well. I know I can get a notification for when the player comes up and disappears, but is there a way to prevent it from rotating the controller in the first place?
It doesn't seem like anyone has an answer. I have all of the standard "don't rotate unless if I tell you to" methods and plist values, but its still rotating. Its only when I load up a webview and the media player loads over it. If I rotate my device, the media player rotates along with it, which feels natural, but when I go back to the webview view controller, its rotated, which isn't good.
Add this key in your info.plist :
UISupportedInterfaceOrientations and set it to UIInterfaceOrientationPortrait
Ok, this a blind shot. I've used this trick to force the system to adjust to the required orientation, add this lines when the webview will appears, or when the player will disappear:
UIViewController *viewController = [[UIViewController alloc] init];
[self presentModalViewController:viewController animated:NO];
[self dismissModalViewControllerAnimated:NO];
Try in some of those methods, or in the didAppear or didDisappear if dosen't work. I know it look like rubbish, but sometimes works.
There doesn't seem to be a correct answer to this question.

UIImagePickerController appears but camera doesn't start on iOS 5

I have an app where I present a UIImagePickerController with source type UIImagePickerControllerSourceTypeCamera. Everything works fine unless I leave the app and come back (multitasking is enabled so the app comes back right where it left off) and I present the UIImagePickerController again. It appears on screen but the camera never shows, the animation where the camera is revealed never happens, here is a screenshot:
If I press cancel and present the UIImagePickerController again, the camera will show up fine. So the only time this problem occurs is the first time I present the UIImagePickerController after coming back to the app. Anyone know why this is happening? I'm coding for iOS 5
I'm presenting the UIImagePickerController with:
[self presentViewController:capturePhotoPicker animated:YES completion:nil];
and dismissing it with:
[self dismissViewControllerAnimated:YES completion:nil];
I am using the same UIImagePickerController object each time I present it
I had exactly the same problem and then realized I wasn't releasing the UIImagePickerController after presenting it. The camera now works fine first-time after leaving and returning to the app.
So this is my exact code:
UIImagePickerController *takePhotoController = [[UIImagePickerController alloc] init];
takePhotoController.sourceType = UIImagePickerControllerSourceTypeCamera;
takePhotoController.delegate = self;
[self presentModalViewController:takePhotoController animated:YES];
[takePhotoController release];
It's one of those problems you can spend ages on, and the solution is not that obvious (well, it wasn't to me), so I hope this helps some people!
if you change the -(void)viewDidLoad to - (void)viewDidAppear:(BOOL)animated it fixes the problem. I've spent the last 2 weeks trying to figure this out

iPad open a modalViewController at application launch

here is my problem: I have an iPad application based on a SplitViewController. When I launch the application, since it always starts in portrait mode, only the Detail pane is shown. All right. I want now open a modalViewController at the application launch for login purpose, but I am not able to find out the right way. I grasp on the web the following code:
SampleModalViewController *sampleView = [[[SampleModalViewController alloc] init] autorelease];
[sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentModalViewController:sampleView animated:YES];
and it runs nicely, but where do I have to place it in order to have the modal controller displayed at startup? I tried to override viewDidLoad in the DetailViewController, but it does not work.
Thanks for your help!
Roberto
They suggested me an answer:
http://forums.macrumors.com/showthread.php?t=1097839

Resources