objective-c how to programatically landscape keyboard when device rotates - ios

I have a UIWebWiew in a UIViewController that I want be able to be in landscapemode.
That is done.
But the keyboard gets stuck still in portraitmode when a textfield is taped.
So I added the redpart of the code
[[UIApplication sharedApplication] setStatusBarOrientation: UIInterfaceOrientationLandscapeLeft];
Because I read that with that the keyboard will decide itself how to rotate. But that did nothing.
Any one got ideas on how I should do?

Related

Disable remote controls iOS

By default, remote control is activated on my streaming application but under a certain circumstance I want to disable all controllers and show nothing when the screen is locked.
First I tried to set now playing info to nil like this [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo: nil]; and all text, image and progress disappear but the control buttons and volume bar was still showing.
After that I tried this [[UIApplication sharedApplication] endReceivingRemoteControlEvents]; but it gives me nothing, it shows the same thing on the screen as the previous method call.
For the record, I'm calling [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; on AppDelegate before I tried to call any of the previous methods.
So, I have not found anything related to this that could help me with my problem and I would appreciate any help :)

iOS 7 red status bar

When Shazam is opened the status bar turns red and doubles it's height because of background recording, but this ruins the UI in my app. I'm now trying to change my code to support different status bar sizes, because the red status bar is also opaque, but I can't come up with a general solution because of this:
When the status bar is initially red, when I launch my app, the launch image is scaled and ruined. How to fix this?
Note: My app does NOT use recording.
[Edit]
The only solution I found was to set 'Status bar is initially hidden' to YES in .plist. I don't really need the status bar to be visible on app launch, especially if it affects my launch image when the status bar is taller than usual, i.e. when recording or during a phone call.
[Edit 2]
There are cases when the launch image will be briefly visible when the app is brought to foreground from background state. To work around this I use view-controller based status bar appearance:
- (BOOL)prefersStatusBarHidden
{
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground)
{
return YES;
}
return NO;
}
This ensures the status bar is always hidden when the app comes to foreground, so the launch image will never be affected. Don't forget to call setNeedsStatusBarAppearanceUpdate on appDidEnterBackground and (inside an animation block) on appDidBecomeActive notifications.
The red status bar is a system function. You are not going to be able to work around this - and it isn't really your 'fault' if the launch screen looks like that - if the user wants to open your app while using Shazam, they are going to see the red bar and the launch image is going to be scaled. You could change the launch image to look good when scaled, but then it would look bad the rest of the time (when the red bar wasn't at the top of the screen on launch).
After a long long long long long research and hurdles I found out simple solution for this follow as below
In Targets->General->Deployment Info check the HideStatusBar Option
like below!
And in the ViewController (Which one you kept as RootViewController) in viewDidAppear add this line of code...
[[UIApplication sharedApplication] setStatusBarHidden:NO];
Because when you uncheck HideStatusBar Option and your app needs any background process or audio related process then the status bar will become red with enlarged height. If you dont want status bar in entire app then dont add the above line in viewDidAppear and check HideStatusBar Option.

Statusbar and layout issues with UIImagePickerController after rotation

tl;dr: User interface layout is broken when rotating the iPad while taking a photo, if the app displays a status bar.
I've got an app that shows a status bar that should take photos through a UIImagePickerController.
I'm running this on an iPad 3, iOS 6 with Xcode 4.51
The first problem I noticed was that if I didn't hide the statusbar via
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
before the call to
[self presentViewController:imagePicker animated:YES completion:nil];
Then the UIImagePickerController would not be shown correctly on the screen. The space for the status bar would still be reserved (but no time or battery information etc. shown) with the result that the controls at the lower end of the screen would be partly off-screen.
So, I added the line
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
before presenting the UIImagePickerController and the first problem was solved.
Now comes the second problem (caused by the solution to the first problem). When I bring up the UIImagePickerController, rotate the iPad and close it (via "cancel" or "use", doesn't matter), the handler (either imagePickerControllerDidCancel or imagePickerController:didFinishPickingMediaWithInfo: gets called, in which I show the status bar again, via
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
The problem is now that the status bar is shown in fact, but the rest of the app seems to be unaware that it is on the screen again. (The UIToolbar that I have on my "MainViewController" is partly hidden behind the status bar.) The interesting thing is, if I rotate the iPad to any other orientation all is displayed correctly again after the animation finishes.
Can anybody give me any tips on how to solve this problem? (Currently my best work around would be to leave the status bar hidden after the first time somebody took a photo, but that's kind of sub-optimal). Maybe there is a better solution to the first problem, or maybe a method to solve both issues.
Further information: After rotating the iPad to landscape while UIImagePickerController was active, this is the frame of my MainViewController's view frame: {{0, 0}, {1024, 768}} (i.e. in the case where there is the problem). When I have the iPad in landscape orientation all the time, this is the MainViewController's view frame after the UIImagePickerController is dismissed: {{0, 0}, {1024, 748}} (This is the case where there is no problem.)
Thanks in advance for your attention and effort!
I just came across the same issue on iPhone when displaying an image picker that takes an image from the camera. The solution I found was to make a call to show the statusbar when the view that popped up the image picker will re-appear. Eg.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
}

iAD - adBannerView rotation

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];

IOS4 UISplitViewController in Portrait Orientation with RootViewController showing like Landscape

In IOS 3.2 I was able to display my UISplitViewController side by side like in landscape mode.
In IOS 4.2 the RootViewController (MasterView) is not showing up in portrait mode. Does anyone know if we need to display the rootviewcontroll in a popover? Can we display it side by side like how it is in landscape mode?
I want to avoid having to click on a button to show the masterview (when in portrait mode)
In that case, you can skip the splitviewcontroller and create only view base application where you could manually control the UI.
on viewDidAppear you can do
[splitViewController setHidesMasterViewInPortrait:NO];
It works even though you get a warning. I think you can create category with a custom splitviewcontroller to get rid of the warning.
2.Otherwise you can do something like
on the viewWillAppear, you can do something like
if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
UIViewController *master = [[splitViewController.viewControllers objectAtIndex:0];
UIViewController *detail = [[splitViewController.viewControllers objectAtIndex:1];
[splitViewController setupPortraitMode:master detail:detail];
}
(setupPortraitMode ) http://intensedebate.com/profiles/fgrios.
I used setHidesMasterViewInPortrait:NO and it did work on the pre-5.0 releases, and even got into the apple store once. But the next time I updated the app, they rejected it because I used a hidden API. I am still searching for a way to make this work.

Resources