I want to switch to another viewController. I have an UIButton on my view, the UIButton have an UILongPressGestureRecognizer by using this code:
UILongPressGestureRecognizer *buttonLongPressRecognizer;
buttonLongPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(LoadButtonSettings:)];
buttonLongPressRecognizer.numberOfTouchesRequired = 1;
buttonLongPressRecognizer.minimumPressDuration = 2.0;
[NewButton addGestureRecognizer:buttonLongPressRecognizer];
The action I use to switch viewControllers are this:
- (IBAction)LoadButtonSettings:(id)sender {
[ButtonSettingsViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:ButtonSettingsViewController animated:YES completion:NULL];
}
The problem is that when I make a long press on the button my app crashes and gives me a SIGABRT error. Weirdly enough it only happens on my iPhone, not on the simulator.
I have also tried using
[self presentModalViewController:ButtonSettingsViewController animated:YES];
and got the same problem. As I know SIGABRT means there’s a memory issue, which I don’t understand since Automatic Reference Counter is on.
Any ideas on how to fix this?
Thanks in advance 🙂
If ButtonSettingsViewController is the type of view controller you need to initialize it first: