Note that there are some explanatory texts on larger screens.

plurals
  1. PO- (void)sendEvent:(UIEvent *)event method iPhone 5.0
    text
    copied!<p>I had to detect if user has touched on the iPhone screen. So, I created a class named "CustomApplication" in my project (subclassing UIApplication) and then, I modified my main.m to look like this:</p> <pre><code>NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, @"CustomApplication",nil); [pool release]; return retVal; </code></pre> <p>This class "CustomApplication.m" contains a method as follows: </p> <pre><code>- (void)sendEvent:(UIEvent *)event { [super sendEvent:event]; [MyUtility showAlertWithTitle:@"Alert!!!!" message:@"Session Expired!!!!"]; // showing an alert here } </code></pre> <p>The Method showAlertWithTitle looks like this:</p> <pre><code>+ (void) showAlertWithTitle:(NSString *)aTitle message:(NSString *)aMessage { UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:aTitle message:aMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; // Line causing problem in iOS 5 - base sdk 5.0 [alertView release]; </code></pre> <p>}</p> <p>Everythings working fine in iOS 4.2, but on iOS 5.0 the app is crashing on touching the screen (when sendEvent:event method gets called). When I debugged the code, I found that the problem is in [alertView show]; line. In iOS 5, what is happening is when this particular line ([alertView show];) gets executed, it again calls sendEvent method of CustomApplication and this method calls showAlertWithTitle: method of MyUtility which in turn again calls sendEvent method and hence, the code is entering into infinite loop. I dont know the solution. If someone has faced this weired thing, then please tell me what should I write so that when alert is being showed the sendEvent method doesn't get called?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload