UIActionSheet messes up shaking detection (motionBegan: delegate) on iPad - 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

Related

iOS 8 keyboard greyed out after app returns from background

In my app when home button is pressed and later the app is put back to the foreground, there is always grey box instead of the system keyboard. No matter what UITextField is pressed, this grey box always appear until the app is killed and started again.
Before entering background, [UITextFiled resignFirstResponder] is called for every UITextField.
I have also tried some other solutions like:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[self.window endEditing:YES];
}
The issue is present even if no resigning is done, simply every entering to background will break the keyboard.
The grey area do not react on touches, all touch events are sent to views below, like there was no grey box at all.
On iOS7, there is no problem. Could it be some iOS system bug?
Thanks for help.
Example screenshot:
http://i.stack.imgur.com/DpVMr.png

How to disable iPhone 'app not active' flashing banner

My app checks the GPS while my app is not the active app and I use AVAudioplayer too in background.
It works fine and stays in the background doing its thing, but ios7 displays this red top banner with my app name flashing on it when it is not the active app.
How can I disable this banner, it is annoying to use other apps that are squished down 1 line?
I know this can be done as I have other GPS based background apps that don't display this flashing banner.
EDIT - So we found the answer quickly but the solution evades me:
If I stop OpenEars pocketsphinxController from listening with a button that calls this method while the program is active, the banner disappears when the app loses focus:
-(void) mystopListening{
NSLog(#"Tried to stop listening");
[pocketsphinxController stopListening];
}
BUT if I call the same method from my app delegate with (I had to import my view controller.h file in my app delegate.h and add -(void) nystopListening; in my view controller.h to make the below execute properly):
- (void)applicationWillResignActive:(UIApplication *)application{
myViewController * vc = [[myViewController alloc]init];
[vc mystopListening];
}
The banner persists! It is a little like ios7 has decided I am a recording culprit before I even have a chance to turn it off. OR, am I even turning it off?
How do I do this effectively and in what event?
EDIT - So it turns out I am not really turning pocketsphinxController off when 'mystopListening' is called from the app delegate. I know this because it DOES log the 'Tried to stop listening' when called from app delegate but the pocketsphinxController does not respond with its 'pocketsphinxDidStopListening' method. PocketsphinxController does call its 'pocketsphinxDidStopListening' method when I call 'mystopListening' from a button while the app is active.
Why won't the pocketsphinxController respond when called from from the app delegate, I must be doing it wrong?
Thanks,Carmen
Turns out I was not really calling the original pockectsphinxcontroller instance from my app delegate.
As a workaround to the problem I did this:
My app always has a timer running, so in my app delegate where I get notice of when app goes to inactive and comes back active, I just set global flags so my timer can know app active status. Then my timer just uses pockecsphinxcontroller methods to stop and start listening and voila, the banner is no more while app not active.

How can I keep UIActionSheet from being dismissed when background touched?

The default behavior for the UIActionSheet used to be that touching the background did not dismiss it, and in fact did nothing. But with iOS 7 touching the background is equivalent to pressing the cancelButton.
I'm modifying some software that needs to be kept to the iOS 6 behavior. How can I keep touches of the background from dismissing the action sheet?
You can achieve this by not using a cancel button.
Check this SO post:
UIActionSheet in iOS7 dismissing when user taps ANYWHERE on the screen on iPhone

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

Popover changes in iOS 5?

I have just developed an iPad app to the point of testing, but did it in iOS 4.3. Now I've updated to 5.0 in the simulator and also went through Apple's steps to test on my iPad which runs 5.0
In the 4.3 simulator all works fine. But in the 5.0 simulator and on the iPad all of my popovers that originate from UIButtons crash the app. I have a popover coming from a navbar button which works fine.
Each popover that crashes will display its contents (a UIWebview with a pdf file), but when I then click anywhere on the screen the app crashes (within the popover and outside).
I can post some code, but hope that this description helps give someone an idea. I don't manually dismiss the popover or check if it is open, but since this doesn't only occur by trying to touch its launching UIButton I don't think that's why it's happening. Plus it works as is under 4.3
Edit: This is solved now thanks to Stephen's comment. I added into the popOver's content viewController:
- (void) dealloc {
[webView release];
[super release];
}
Usually I would call [super dealloc] instead of [super release], but [super dealloc] didn't fix the exception (exc_bad_access). Hopefully I haven't put a sloppy patch on the problem!
I had a thread started to collect bugs like this, but the forum police quashed it. Suffice it to say that iOS 5 is riddled with incompatibilities.
I can't say with any certainty what your problem is, but there's a good chance it has to do with the changes to UINavigationController, which caused UIViewController's navigationController to be nil for popups, with parentViewController taking its place.
Unfortunately, parentViewController is new, so you must, eg, test respondsToSelector:#selector(parentViewController) and take parentViewController if it exists, otherwise navigationController.
Had to add this logic in about 30 places in an app we have.

Resources