objective-c - UIBarButtonItem 不继承 UIView 的原因是什么?

标签 objective-c cocoa-touch uibarbuttonitem

<分区>

UIBarButtonItem 继承自 UIBarItem,它是 NSObject 的直接后代。

UIBarItem 只不过是一种特殊的 UIButton,您可以将其添加到 Bar。

来自 Apple 文档:

Items on a bar behave in a way similar to buttons (instances of UIButton). They have a title, image, action, and target. You can also enable and disable an item on a bar.

那么谁能解释一下为什么要“特殊”对待?

只是出于好奇。谢谢

最佳答案

我相信 Apple 不希望人们在 UIToolbar 或 UINavigationBar 之外使用 UIBarItem。您不能将 UIBarItem 作为 subview 添加到任何其他 View ,因为它不继承自 UIView。我只是猜测,所以可能会有更好的解释......

关于objective-c - UIBarButtonItem 不继承 UIView 的原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10103096/

相关文章:

ios - 第一次运行时从 NSUserDefaults 将图像作为 NSData 加载失败

ios - 通过在 lldb 中添加 borderColor 来调试 View

iOS 限制 64 个本地通知

javascript - Objective-C 从网页获取图像

iphone - 不同的 NSNumberFormatter 行为

swift - UINavigationController 标题与 UIBarButton 不对齐

iphone - iOS 上的 Safari 'Top Sites' 样式

ios - Swift: 将 UIView 设置为 UIBarButton/UIButton 的背景

swift - 没有为 UIBarButtonItem 调用 iOS 选择器

ios - 在 IOS 中获取错误的运营商名称