Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

IDMah

macrumors 6502
Original poster
May 13, 2011
317
11
Hi all.

I have a ViewController with a uiview with a UIAlertview on it. It all works fine ... Until.. Dun dun Dahh!
Some user goes and presses the home button and drops the app into Background.

When they come back to the Alert is there, the information is correct but
you can't type on the keyboard, it auto dismisses.. Is there any why to restore
I guess the delegate?

** is there a universal good way of searching for a Active UIAlertView ???

or Do I have to dismiss the UIAlert and then put it back when they come back.
if so, how do I get the view to know that the we are entering background?


actual examples help the most..
Thanks
Ian
 
Last edited:
Ok .. I've now removed the UIAlert when I enter Background.

So figure I would just create a new alert and all would be good.
but Keyboard still dismisses itself.

Yes: I have:
Code:
 [[winAlert  textFieldAtIndex:0] becomeFirstResponder];
Does nothing. Do I have to remove the window? So fluxed!
and I do:
Code:
 [[winAlert  textFieldAtIndex:0] resignFirstResponder];

thanks
Ian
 
Last edited:
Related Problem UIAlertView Persistent

Just noticed that exiting my app with a UIAlertview on the screen does bad things. (crashes and burns) .. sigh...

So, I think this basically it's a problem with UIAlertviews in general not being retained properly after Entering background.

Any hints on how to make it more robust???

thanks
Ian
 
Closer

Dude. As per Apple recommendations.

1. Remove UIAlertView when you go to the background.
2. create an instance variable to retain the UIALertView.
3. then..

Code:
- (void)applicationDidEnterBackground:(UIApplication *)application {
        if (alertMan) {
        [self.alertMan dismissWithClickedButtonIndex:0 animated:NO];
        [alertMan setDelegate:nil]; // <---- this seem fix all the worlds woes !! 
        alertShow=NO;
        alertMan = nil;
    }
}

This seems to prevent the crashing but doesn't help the bouncy keyboard.
 
Last edited:
Log

Been banging my head on this rock for a week now !!!
Help please !!!

Code:
2014-03-31 12:59:23.192 DragonEmperorsChallenge[4043:60b] -[__NSCFDictionary renderingMode]: unrecognized selector sent to instance 0xa556dd0
2014-03-31 12:59:23.278 DragonEmperorsChallenge[4043:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary renderingMode]: unrecognized selector sent to instance 0xa556dd0'
*** First throw call stack:
(
	0   CoreFoundation                      0x0266a1e4 __exceptionPreprocess + 180
	1   libobjc.A.dylib                     0x023e98e5 objc_exception_throw + 44
	2   CoreFoundation                      0x02707243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
	3   CoreFoundation                      0x0265a50b ___forwarding___ + 1019
	4   CoreFoundation                      0x0265a0ee _CF_forwarding_prep_0 + 14
	5   UIKit                               0x00d733bf -[UIImageView _shouldTreatImageAsTemplate:] + 34
	6   UIKit                               0x00d73c82 -[UIImageView _effectiveTintColorWithImage:] + 42
	7   UIKit                               0x00d73cfd -[UIImageView tintColorDidChange] + 90
	8   UIKit                               0x00ee1c12 -[_UITintColorVisitor _visitView:] + 363
	9   UIKit                               0x00ee241f _UIViewVisitorEntertainVisitors + 98
	10  UIKit                               0x00ee149c _UIViewVisitorRecursivelyEntertainDescendingVisitors + 172
	11  UIKit                               0x00ee155e _UIViewVisitorRecursivelyEntertainDescendingVisitors + 366
	12  UIKit                               0x00ee155e _UIViewVisitorRecursivelyEntertainDescendingVisitors + 366
	13  UIKit                               0x00ee122e +[_UIViewVisitor _startTraversalOfVisitor:withView:] + 380
	14  UIKit                               0x00c621c4 -[UIView _receiveVisitor:] + 50
	15  UIKit                               0x00c65556 -[UIView _dispatchTintColorVisitorWithReasons:] + 149
	16  UIKit                               0x00c65dce -[UIView _beginOcclusion:] + 74
	17  UIKit                               0x00db7f5c -[_UIModalItemsPresentingViewController _desaturateUI] + 368
	18  UIKit                               0x00db9737 -[_UIModalItemsPresentingViewController _dismissItem:andPresentItem:animated:completion:keepDimmingView:] + 465
	19  UIKit                               0x00dbbef7 -[_UIModalItemsPresentingViewController _dismissItem:andPresentItem:animated:completion:] + 70
	20  UIKit                               0x011ef90b -[_UIModalItemsCoordinator _presentItem:replacingItem:inViewController:animated:] + 2360
	21  UIKit                               0x00fb0dfb -[UIViewController(UIModalItemPresentationSupport) presentModalItem:replacing:animated:dontPresentAndAddToStack:] + 132
	22  UIKit                               0x00fb0ecc -[UIViewController(UIModalItemPresentationSupport) presentModalItem:animated:] + 64
	23  UIKit                               0x0111f056 -[UIAlertView popupAlertAnimated:animationType:atOffset:] + 1094
	24  UIKit                               0x0111f327 -[UIAlertView popupAlertAnimated:animationType:] + 56
	25  UIKit                               0x0112435c -[UIAlertView showWithAnimationType:] + 48
	26  UIKit                               0x0112438a -[UIAlertView show] + 41
	27  Foundation                          0x0084c94f -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:] + 863
	28  Foundation                          0x0084c55c -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] + 159
	29  DragonEmperorsChallenge             0x00042ce8 -[HighScoreViewControl showWinAlert] + 1240
	30  Foundation                          0x008335ec __NSFireDelayedPerform + 372
	31  CoreFoundation                      0x02628ac6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
	32  CoreFoundation                      0x026284ad __CFRunLoopDoTimer + 1181
	33  CoreFoundation                      0x02610538 __CFRunLoopRun + 1816
	34  CoreFoundation                      0x0260f9d3 CFRunLoopRunSpecific + 467
	35  CoreFoundation                      0x0260f7eb CFRunLoopRunInMode + 123
	36  GraphicsServices                    0x038075ee GSEventRunModal + 192
	37  GraphicsServices                    0x0380742b GSEventRun + 104
	38  UIKit                               0x00c0ff9b UIApplicationMain + 1225
	39  DragonEmperorsChallenge             0x0001572d main + 125
	40  libdyld.dylib                       0x02f07701 start + 1
	41  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Another one at the same spot.. I think..
Code:
2014-04-01 14:44:48.057 DragonEmperorsChallenge[2012:60b] -[__NSArrayM renderingMode]: unrecognized selector sent to instance 0xa6f8ee0
2014-04-01 14:44:48.080 DragonEmperorsChallenge[2012:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM renderingMode]: unrecognized selector sent to instance 0xa6f8ee0'
*** First throw call stack:
(
	0   CoreFoundation                      0x026691e4 __exceptionPreprocess + 180
	1   libobjc.A.dylib                     0x023e88e5 objc_exception_throw + 44
	2   CoreFoundation                      0x02706243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
	3   CoreFoundation                      0x0265950b ___forwarding___ + 1019
	4   CoreFoundation                      0x026590ee _CF_forwarding_prep_0 + 14
	5   UIKit                               0x00d723bf -[UIImageView _shouldTreatImageAsTemplate:] + 34
	6   UIKit                               0x00d72c82 -[UIImageView _effectiveTintColorWithImage:] + 42
	7   UIKit                               0x00d72cfd -[UIImageView tintColorDidChange] + 90
	8   UIKit                               0x00ee0c12 -[_UITintColorVisitor _visitView:] + 363
	9   UIKit                               0x00ee141f _UIViewVisitorEntertainVisitors + 98
	10  UIKit                               0x00ee049c _UIViewVisitorRecursivelyEntertainDescendingVisitors + 172
	11  UIKit                               0x00ee055e _UIViewVisitorRecursivelyEntertainDescendingVisitors + 366
	12  UIKit                               0x00ee055e _UIViewVisitorRecursivelyEntertainDescendingVisitors + 366
	13  UIKit                               0x00ee022e +[_UIViewVisitor _startTraversalOfVisitor:withView:] + 380
	14  UIKit                               0x00c611c4 -[UIView _receiveVisitor:] + 50
	15  UIKit                               0x00c64556 -[UIView _dispatchTintColorVisitorWithReasons:] + 149
	16  UIKit                               0x00c64e1f -[UIView _endOcclusion:] + 74
	17  UIKit                               0x00db7131 -[_UIModalItemsPresentingViewController _resaturateUI] + 345
	18  UIKit                               0x00dba6b9 __105-[_UIModalItemsPresentingViewController _dismissItem:andPresentItem:animated:completion:keepDimmingView:]_block_invoke248 + 755
	19  UIKit                               0x00c756b2 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 484
	20  UIKit                               0x00c7c708 +[UIView(Internal) _animateUsingSpringWithDuration:delay:options:mass:stiffness:damping:initialVelocity:animations:start:completion:] + 187
	21  UIKit                               0x00c7c819 +[UIView(Internal) _animateUsingSpringWithDuration:delay:options:mass:stiffness:damping:initialVelocity:animations:completion:] + 128
	22  UIKit                               0x00c7ca2d +[UIView(Internal) _animateUsingDefaultDampedSpringWithDelay:initialSpringVelocity:options:animations:start:completion:] + 444
	23  UIKit                               0x00c7ca87 +[UIView(Internal) _animateUsingDefaultDampedSpringWithDelay:initialSpringVelocity:options:animations:completion:] + 84
	24  UIKit                               0x00c7c86c +[UIView(Internal) _animateUsingDefaultTimingWithOptions:animations:completion:] + 78
	25  UIKit                               0x00db972d -[_UIModalItemsPresentingViewController _dismissItem:andPresentItem:animated:completion:keepDimmingView:] + 4551
	26  UIKit                               0x00dbaef7 -[_UIModalItemsPresentingViewController _dismissItem:andPresentItem:animated:completion:] + 70
	27  UIKit                               0x011ef466 -[_UIModalItemsCoordinator _dismissItem:withTappedButtonIndex:animated:notifyDelegate:] + 837
	28  UIKit                               0x00d2417b -[_UIModalItemAlertContentView tableView:didSelectRowAtIndexPath:] + 958
	29  UIKit                               0x00cf89a1 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1513
	30  UIKit                               0x00cf8b14 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 279
	31  UIKit                               0x00cfd10e __38-[UITableView touchesEnded:withEvent:]_block_invoke + 43
	32  UIKit                               0x00c2c0aa ___afterCACommitHandler_block_invoke + 15
	33  UIKit                               0x00c2c055 _applyBlockToCFArrayCopiedToStack + 403
	34  UIKit                               0x00c2be76 _afterCACommitHandler + 532
	35  CoreFoundation                      0x0263136e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
	36  CoreFoundation                      0x026312bf __CFRunLoopDoObservers + 399
	37  CoreFoundation                      0x0260f254 __CFRunLoopRun + 1076
	38  CoreFoundation                      0x0260e9d3 CFRunLoopRunSpecific + 467
	39  CoreFoundation                      0x0260e7eb CFRunLoopRunInMode + 123
	40  GraphicsServices                    0x038065ee GSEventRunModal + 192
	41  GraphicsServices                    0x0380642b GSEventRun + 104
	42  UIKit                               0x00c0ef9b UIApplicationMain + 1225
	43  DragonEmperorsChallenge             0x0001510d main + 125
	44  libdyld.dylib                       0x02f06701 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
 
week 3 Log "we are lost in space with no hope of returning home.."

Can't figure it out.. simply calling the alert responding pressing <OK> to it and pressing to the home button. Then going back and triggering the alert again causes it to crash with.

Code:
** -[UIImage class]: message sent to deallocated instance 0xa525a70
and 
exc_breakpoint (code=exc_i386_bpt subcode=0x0)

but says it happens on.

Code:
[myAlertview show]
//or
[myAlertview performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];

Help !
thanks
Ian
 
Well looks like crashes had to do with a released, UIImage.
Which only seemed to crash when The UIAlerts came into play.. Shrug!

Still fighting the bouncing Keyboard, which also only happens when
we enter background. So not going to mark this resolved, just yet.

Any suggestions. Tried a billion of combinations of becomeFirstResponder and delegates. So annoying since code is so small.

thanks
Ian
 
Keyboard problems persist.

I tried calling:
Code:
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showingKey) name:UIKeyboardDidShowNotification object:nil];
   
//
- (void) showingKey
{
    NSLog(@"showing Keyboard");
    
}

Keyboard is getting called X++ times. So every time I show the alert it calls the keyboard one more time. But I pretty sure there is only one UIAlertview

but I get:
Code:
2014-04-13 10:59:14.990 DragonEmperorsChallenge[1141:60b] showing Keyboard
2014-04-13 10:59:14.990 DragonEmperorsChallenge[1141:60b] showing Keyboard
2014-04-13 10:59:14.990 DragonEmperorsChallenge[1141:60b] showing Keyboard
2014-04-13 10:59:14.991 DragonEmperorsChallenge[1141:60b] showing Keyboard
2014-04-13 10:59:14.991 DragonEmperorsChallenge[1141:60b] showing Keyboard

later run:
Code:
2014-04-13 11:07:52.033 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:52.034 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:52.034 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:52.034 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:52.034 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:52.035 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:52.035 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:58.507 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:58.507 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:58.508 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:58.508 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:58.508 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:58.508 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:07:58.509 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:08:02.550 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:08:02.553 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:08:02.553 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:08:02.553 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:08:02.553 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:08:02.554 DragonEmperorsChallenge[1219:60b] showing Keyboard
2014-04-13 11:08:02.554 DragonEmperorsChallenge[1219:60b] showing Keyboard
any ideas???
 
Last edited:
Finally decide to ARC the whole project.. Solved all the worlds problems !!!
no more Double, triple, Quad.. Keyboards.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.