Reputation: 600
I'm getting the above warnings using Xcode 5 with a deployment target set to iOS 5.0.
I'm not sure whether to simply ignore these warnings OR find an alternative way of providing this functionality for iOS5.
As far as I can see I have a number of imperfect solutions:
Option 1: present the MainStoryboard programmatically for iOS6+; replace modal segues on a different storyboard for iOS5 with
presentViewController:animated:completion:
Option2: would be to drop modal segues entirely from the storyboard(s), calling any segues within IBAction methods
Option3: ignore the warnings (would the app still be accepted?).
(Yes, I'm aware of "target iOS6+ only" as an option)
I'd appreciate advice from those who've found ways to solve this problem.
Update: solved this thanks to Mikael's answer below: I subclassed UIStoryboardSegue as below
#import "StandardModalSegue.h"
@implementation StandardModalSegue
- (void) perform {
//my conditional version of NSLog()
myLog(kLogVC, 2, @"%@ to %@",self.sourceViewController ,self.destinationViewController);
//iOS5 replacement for presentModalViewController:animated:
[self.sourceViewController presentViewController:self.destinationViewController animated:YES completion:nil];
}
@end
and used it in storyboard thus
PS: accepting Mikael's answer, this here to help newbies like me!
Upvotes: 0
Views: 383
Reputation: 5845
It's the animate checkbox in interface builder that creates this error. If you want to get rid of it and not animate your modal segue you need to create a custom segue and override -(void) perform
All you have to do is keep the segues you have now but set them to custom. Then you create a subclass of UIStoryboardSegue. In the implementation file you put:
- (void)perform
{
// Add your own animation code here.
[[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO];
}
You can then use this segue like any other segue. If it's attached to a UIButton it gets called automatically and you do not need performSegue. If not you can use the performSegue that is compatible with iOS5 or even choose a performSegue depending on the version of OS.
Upvotes: 1