I have tried to use a private method to put the app in background after pressing the Menu button; and the following code works properly:
@implementation ViewController {
UITapGestureRecognizer *tapRecognizer;
}
-(void)viewDidLoad {
[super viewDidLoad];
tapRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
tapRecognizer.allowedPressTypes = @[[NSNumber numberWithInteger:UIPressTypeMenu]];
[self.view addGestureRecognizer:tapRecognizer];
}
-(void)handleTap:(UITapGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateEnded) {
NSLog(@"Menu button released");
UIApplication *app = [UIApplication sharedApplication];
[app performSelector:@selector(suspend)];
}
}
But I would like to get the same result without using the private method "suspend" because Apple could reject the app due to using a private method.
[app performSelector:@selector(suspend)];
Any suggestion will be appreciated