gpt4 book ai didi

iphone - UINavigationBar 调用 drawRect : if subclassed but not when using categories in iOS 5?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:20:34 24 4
gpt4 key购买 nike

我在一个以 iOS 4.0 为目标的项目中使用 iOS 5 SDK,我注意到如果我继承 UINavigationBar 类以覆盖 drawRect: 方法,它会被调用,但这不会从 UINavigationBar 类创建类别时不会发生这种情况。

有人知道为什么会这样吗?我应该误解了类别之类的东西,因为这种行为对我来说毫无意义。

编辑:我在 iOS 5 上运行应用程序。

最佳答案

iOS 5.0 SDK Release Notes, UIKit :

In iOS 5, the UINavigationBar, UIToolbar, and UITabBar implementations have changed so that the drawRect: method is not called unless it is implemented in a subclass. Apps that have re-implemented drawRect: in a category on any of these classes will find that the drawRect: method isn't called. UIKit does link-checking to keep the method from being called in apps linked before iOS 5 but does not support this design on iOS 5 or later. Apps can either:

  • 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.

关于iphone - UINavigationBar 调用 drawRect : if subclassed but not when using categories in iOS 5?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7798343/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com