English 中文(简体)
UINavig 律师求助电话:如果是分级,而不是在使用5类。
原标题:UINavigationBar calling drawRect: if subclassed but not when using categories in iOS 5?
  • 时间:2011-10-17 19:11:22
  •  标签:
  • iphone
  • ios

我在把SiSD4.0作为目标的项目中使用SOS 5K,我已注意到,如果I子把UINavigation Bar类别压倒drawRect:。 这种方法被称作,但在从美国航空研究院中创立一个类别时确实如此。 班级。

没有人知道为什么发生这种情况? 我应该有误解的类别或内容,因为这种行为对我没有意义。

Edit: I m主持5号SOS申请。

最佳回答

iOS 5.0 SDK Release Notes, UIKit:

http://www.un.org/Depts/DGACM/index_chinese.htm 除非在子类内实施,否则不采用这种方法。 重新实施<代码>drawRect:的任一类别中的应用将发现drawRect: 这种方法被指。 IDKit的确把检查联系起来,以便把这种方法从连接到SOS 5,但并不支持这一设计。 申请也可以:

  • Use the customization API for bars in iOS 5 and later, which is the preferred way.
  • Subclass UINavigationBar (or the other bar classes) and override drawRect: in the subclass.
问题回答

类别和子类别之间存在差异。 继承涉及继承,这意味着你可以凌驾于实施方法之上,例如<代码>drawRect:。 一种类别用于在现有类别中增加方法,也称为延伸。

例如,为了在国家统计部门增加一种方法,你可以设立这样的类别:

@interface NSString (MyStringAdditions)
- (void)doSomething;
@end

另一种选择是等同级:

@interface MyStringClass : NSString
- (void)doSomething;
@end

差异在于可用性。 如果你下级,你就不得不用这种子级来说明这些方法。 如果你使用某种类别,你的新方法将针对现有类别的所有物体。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签