I am creating a game specifically designed to be played using Switch access. The game builds a grid of buttons dynamically based on the level to mimic the grid layout of an iPad's icons. With the nature of switch access I cannot have a back button to return to the main menu as this will get counted within the game as a button and included in the tabbing through the user will be doing.
Ideally I would like the user to be able to return to the main menu on a long press of one of the switch buttons, I have tried attaching a Long press gesture recogniser onto the view that the buttons were drawn to, this worked fine in the simulator but not with the switch access button press, I then tried to attach it to each button, again this worked in the simulator but not in actual testing.
Here is the code I am using which works in the simulator.
Adding UILongPressGestureRecognizer to the button.
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(UILongPressBack:)];
[self.button addGestureRecognizer:longPress];
Method called on longpress.
- (IBAction)UILongPressBack:(UILongPressGestureRecognizer*)sender {
if (sender.state == UIGestureRecognizerStateEnded) {
MainViewController * mainPage = [[MainViewController alloc]init];
[self presentViewController:mainPage animated:YES completion:nil];
}
}
From what I understand the switch access controls work just like a bluetooth keyboard (which is how I am testing at the moment). When setting up the switch access buttons I map each one to a certain keyboard key.
Does anyone know how I can get this working? I had considered disabling a button while the game is in play and re-enabling it between levels but then the user doesn't have the option to return the main menu mid game if they wish, which I feel would be bad design.
Thanks for any help.