質問

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;
}
役に立ちましたか?

解決

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

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top