Will iAds be loaded, if I hide the ADBannerView? - iphone

I know Apple recommends just placing the adview offscreen,
incase there is an error, loading an iAd,
but I would like to hide it using [adView setHidden: YES];.
If I do so, will the view check for new ads available?
In the simulator sure it will load the Test Ads,
but will it also work after releasing the app onto actual devices from the AppStore?
SideSwipe

Yes, it should work on real device.

Related

Play video on landscape and force app return to portrait

I used MPMoviePlayerViewController to play a video and when back to app, I need app force return portrait
I think the best way to solve this is by using
https://stackoverflow.com/a/13800907/620197
These are callbacks who only gets called when the user autorotates - you can tell the user to rotate the device and then the autorotate callback will be called and will show only the supported orientation.
If you still want force rotation i believe you need to dismiss the controller - try this and please do tell me if it worked out for you:
IOS 6 force device orientation to landscape
I have searched the web for a long time for a force rotation solution that will please me with no success, it almost looks like apple
Doesnt want us to be able to so this.

iPhone app autorotates on one device, but not another

Does anyone know of a reason why an iPhone would autorotate on one device, but not another? I can't reproduce it on my iPhone, iPod Touch, or any of the simulator devices.
Are there any device settings I should be paying attention to? The offending iPhone has the same SDK version installed (4.2.1), but is a different model (MC319LL) than mine (MC605DN).
Well, I never figured out why the two phones were acting differently, but this bit of code in in the UITabBarController subclass seems to have solved things:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return toInterfaceOrientation == UIInterfaceOrientationPortrait;
}
You made sure that the misbehaving device had its rotation lock turned off in the settings, right?

Setting MPMoviePlayer controlStyle to MPMovieControlStyleNone crashes app

I have an app which uses a manager to offer up the relevant custom view for a selected item when selected.
The selection is done through one of 3 parent custom views
TableView
PageControl
Gallery (essentially another TableView)
One of the custom views displays a view with an embedded MPMovieControl on it.
This works fine however for some reason in the Gallery view if I have set the controlStyle of the video set to MPControlStyleNone the app crashes, well it locks up the simulator and Xcodes debugger doesnt even notice, just assumes its still running.
This line is the culprit
player.controlStyle = MPMovieControlStyleNone;
Without it, it works fine, but then I obviously have the unrequired controls displayed
iOS 2.0 through iOS 3.1 uses movieControlMode. Everything newer uses controlStyle. Test for newer and fall back to older.
if ([movie respondsToSelector:#selector(setControlStyle:)]) {
movie.controlStyle = MPMovieControlStyleNone;
} else {
movie.movieControlMode = MPMovieControlModeHidden;
}
May be this will work.
[player setControlStyle:MPMovieControlStyleNone];
Run the program using the profiler and check for NSZombies. Most likely the app is crashing due to a wrong release count or an autorelease and the symptom is your movie crashing when it might be something related to you starting the movie and needing it later to find it was released.

iPad rotation bug when using MPMoviePlayerViewController

Issue summary
Changing the orientation of an iPad device or simulator while playing a video using MPMoviePlayerViewController results in an inconsistent rotation state upon dismissal of the video player. This is a known bug in iPad SDK 3.2, documented at http://www.openradar.me/8012810
Sample project
I have prepared a minimal sample project using the View-based Application template from Xcode 3.2.2, using the following code to launch the player
NSURL *movieUrl = [NSURL URLWithString:#"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:movieUrl];
[self presentMoviePlayerViewControllerAnimated:player];
[player release];
The code is available on GitHub at http://github.com/adamalex/FullScreenMovie or direct download using http://github.com/adamalex/FullScreenMovie/zipball/master
Steps to reproduce
Obtain the project using the information above
Launch the project with the iPad simulator or device
Tap the button to begin playing the video
Rotate the iPad by 90 degrees
Dismiss the video
Note the UIStatusBar is out of sync with the application UI
Objective
I have contacted Apple and they have confirmed this is a bug that is being investigated. I would like to discuss temporary workarounds that use public APIs safe for submission to the App Store. I am going to open a developer support case with Apple as well and will report back with my own progress.
Successful response from Apple Developer Technical Support!
This is a known bug and a we're received a number of duplicate bug reports and so iOS engineering is aware of the issue and we do have a temporary workaround as suggested by iOS engineering.
You will need to implement this in the view controller which presents the movie player.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[self performSelector:#selector(fixStatusBar) withObject:nil afterDelay:0];
}
- (void)fixStatusBar {
[[UIApplication sharedApplication] setStatusBarOrientation:[self interfaceOrientation] animated:NO];
}
While this is somewhat ugly, it should fix the issue for now. It would be recommended to remove this code once the bug is fixed in the system.
This took care of the issue completely for me, and you can revisit http://github.com/adamalex/FullScreenMovie for the code with the fix applied.
This also solves an iPhone/iPodTouch rotation issue that I was struggling with. I am developing a universal app in which each view displays a different image depending on whether the device is in portrait or landscape orientation. Buttons are used to navigate between views.
If the app is running on the device and a portrait view is rotated to landscape, my image switching takes place. If the device is then placed flat on a table top and the button is tapped to display the next view, the view appears in landscape but shows the portrait image instead. I solved the problem by forcing a portrait view to appear by detecting for face up and down, but Apple's code solved this problem (as well as the similar movie problem I was also experiencing).
Many thanks for reporting the bug - I assumed it was just my bad coding...

How to show AdMob ads in real iPhone device?

I want to integrate AdMob ads in my iPhone app. I'm using IB way to add the view and follow AdMob's pdf guide:
1. Add AdMob group(AdMobView.h,AdMobDelegateProtocol.h,libAdMob.a)
2. Add required frameworks(AudioToolbox,MediaPlayer,MessageUI,QuartzCore)
3. Add TouchJSON group
4. Add IBSupport group(AdViewController.h,AdViewController.m)
5. Add a 320*48 UIView in IB, add NSObject and change its class to AdViewController,
link AdViewController's view to the 320*48 UIView and link AdViewController's viewController to current view controller.
Now the iPhone simulator can show ads from AdMob, but when I test it on real device, I get the error "AdMob: Did fail to receive ad".
I've tried to add test device's UDID to testDevices array, but still get the same error.
- (NSArray *)testDevices {
return [NSArray arrayWithObjects: ADMOB_SIMULATOR_ID, DEVICE_UDID, nil];
}
Is there any problem in the above steps? Does anybody know why can't I get the ads in real device? By the way, what should be changed to build for real for-sale app, not just for test?
Setting testDevices seems not working for my test device. I've added a deprecated method -(BOOL)useTestAd according to AdMob wiki and it works now.
- (BOOL)useTestAd {
return NO;
}