I have created a category of UIViewController
to take care of some view controller oddities in iOS 7. Without disclosing any APIs under NDA here is the overridden init
method:
@implementation UIViewController (ios7)
-(id)init {
self = [super init];
if (self) {
if ([self respondsToSelector:@selector(<iOS7OnlyMethod>)]) {
// additional setup
}
}
return self;
}
@end
I verified that the condition fires when running in 7.0 simulator, and doesn't fire if run in 6.1 simulator.
Here is the puzzle: although the code is not run, the tab bar icons of my tab bar disappear in 6.1. However, if I uncheck my target in the file inspector of this .m
file (i.e. I do not include it in the compilation), the tab bar items appear as usual.
How is this possible?
EDIT
After some thinking about this I figured out that I am probably overriding the init
method of UIViewController
- so each UIViewController
is initialised only with the init
of UIResponder
and the additional code (or not) that I provide. Presumably, UIViewController
has much more and critical things in its init
method which I have circumvented in this way.
The problem is, I have a huge project with many view controllers. It should work in iOS 6 and iOS 7. I thought with a category, I can avoid amending all view controllers in the project.
How to solve this? Is there maybe another method that can be overridden instead?