If your category is redefining a base class method you should use subclassing and only use the new class for the iPhone. If you're adding new functionality you could use a MACRO such like IS-IPAD which you'd define reading the device idiom and make conditional execution for iPhone - iPad
Enable category only for iPhone
-
19-07-2023 - |
Pregunta
I have iPhone and iPad project. I use some UINavigationBar category for iPhone. On iPad it not works. I want to disable it. How can I enable it on for iPhone?
- (CGSize)sizeThatFits:(CGSize)size{
size.width = self.frame.size.width;
size.height = 90;
return size;
}
Solución
Otros consejos
I don't know why you would want to do this, but, generally when you have a project that involves both iPhone and iPad, if there is differences in code then you would have 3 classes.
- ClassBase
- ClassIPhone : ClassBase
- ClassIPad : ClassBase
and you would simply import the category into your ClassIPhone class and not your ClassIPad class
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow