When changed UIApplicationMain to use my custom delegate, getting a black screen

I created application delegate subclass UIApplication. Then modified main.m to tell UIApplicationMain to use my custom delegate class ( ELCUIApplication) as the principal class: But now i’m getting a black screen when open the app.

 #import "ELCUIApplication.h"

 @implementation ELCUIApplication

- (void)sendEvent:(UIEvent *)event {
[super sendEvent:event];

// Fire up the timer upon first event
if(!_idleTimer) {
    [self resetIdleTimer];
}

// Check to see if there was a touch event
NSSet *allTouches = [event allTouches];
if ([allTouches count] > 0) {
    UITouchPhase phase = ((UITouch *)[allTouches anyObject]).phase;
    if (phase == UITouchPhaseBegan) {
        [self resetIdleTimer];         
    }
  }
}

- (void)resetIdleTimer 
{
if (_idleTimer) {
    [_idleTimer invalidate];
}

// Schedule a timer to fire in kApplicationTimeoutInMinutes * 60
int timeout = kApplicationTimeoutInMinutes * 60;
_idleTimer = [NSTimer scheduledTimerWithTimeInterval:timeout
                                              target:self 
                                               selector:@selector(idleTimerExceeded) 
                                            userInfo:nil 
                                             repeats:NO] ;

 }
 - (void)idleTimerExceeded {
/* Post a notification so anyone who subscribes to it can be notified when
 * the application times out */ 
[[NSNotificationCenter defaultCenter]
 postNotificationName:kApplicationDidTimeoutNotification object:nil];
}

- (void) dealloc {
 // [_idleTimer release];
 // [super dealloc];
 }

 @end

main.m

  #import <UIKit/UIKit.h>
 #import "AppDelegate.h"
#import "ELCUIApplication.h"

int main(int argc, char * argv[])
{
    @autoreleasepool {
       return UIApplicationMain(argc, argv, nil,     NSStringFromClass([ELCUIApplication class]));
  }
}


Source: ios

Leave a Reply