- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 UINavigationBar 类的子类。在 viewDidLoad 中我有:
- (void)viewDidLoad
{
[super viewDidLoad];
UINavigationBar *bar = [[UINavigationBar alloc] init];
NSString* path = [[NSBundle mainBundle] pathForResource:@"topbanner" ofType:@"png" inDirectory:@"assets"];
NSData *data = [NSData dataWithContentsOfFile:path];
UIImage *image = [UIImage imageWithData:data];
[[UINavigationBar appearance] setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; //crash here!
[self.view addSubview:bar];
}
我从我的 tableView 中调用它。当我在模拟器上运行时一切正常,当我尝试在设备应用程序上运行时崩溃。我有一个错误:
+[UINavigationBar appearance]: unrecognized selector sent to class 0x3e3fe490
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UINavigationBar appearance]: unrecognized selector sent to class 0x3e3fe490'
为什么?
编辑:我的 topbanner 文件位于 Xcode 的 blue 目录文件夹中。在模拟器中一切看起来都很好。
编辑2:当然,当我在我的设备中删除这行代码时,我的应用程序看起来不错,但导航栏 (oc) 上没有图像。
最佳答案
appearance
方法是 iOS 5.0 的新方法。您可能正在使用 iOS 5.0 的模拟器,但您的设备可能使用较低的 iOS 版本。
在使用此方法调用respondsToSelector 修改外观之前,最好先检查respondsToSelector。
来自 UINavigationBar 文档:
Prior to iOS v5.0, when used in conjunction with a navigation controller, there are only a handful of direct customizations you can make to the navigation bar. Specifically, it is alright to modify the barStyle, tintColor, and translucent properties, but you must never directly change UIView-level properties such as the frame, bounds, alpha, or hidden properties directly. In addition, you should let the navigation controller manage the stack of navigation items and not attempt to modify these items yourself.
关于objective-c - 仅在设备上出现 UINavigationBar 外观错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10587136/
您可以将自定义皮肤/外观应用于 SSMS 吗?我正在考虑类似于大多数 IDE 中的深色主题(黑色背景、黄色字体)的做法 最佳答案 我决定在 SSMS 2012 上尝试一些简单的操作: 转到http:/
WordPress主题开发中如何在外观部分显示菜单选项?我可以看到主题、自定义和编辑器选项。这段代码有什么问题- function pietergoosen_theme_setup() { reg
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 9 年前。 Improv
我正在我的一个项目中使用 JTabbedPane,并且我正在尝试更改应用程序的外观和感觉。当我设置窗口的外观和感觉(以及与此相关的任何其他外观和感觉)时,所有按钮、检查按钮等都会更改为它们应该的外观,
如何更改使用 SFAuthenticationSession 时显示的 SafariVC 上的tintColor 和 barTintColor? 我尝试更改 UINavigationBar 、 UIT
我想让 editText 看起来像这样: 设置editText的背景后我还应该做什么如何通过代码让文本在edittext中开始。 最佳答案 您是否想让 EditText 默认说“用户名”,但不是实际的
我在 didFinishLaunchingWithOptions 末尾使用以下代码 [[UITableViewHeaderFooterView Appearance] setTintColor:[UI
我的 ActionBar 中有 android.support.v7.widget.ShareActionProvider 菜单。 当我点击“分享”时,应用列表显示为弹出菜单。 当我在 Google
在使用 shiny 作为调查工具时,我想将 slider 用作“李克特式问题”。 因此,我想自定义 slider 末端的标题,使其有点像“我完全同意”和“我完全不同意”。有没有一种流畅的方法可以做到这
我正在阅读 Laravel 文档,试图更深入地了解该框架,但我在外观方面遇到了一些麻烦。我想我明白它们是什么,它们主要是为了方便访问 Laravel 核心而使用。 我对这个主题感到困惑: How do
我正在制作一款游戏,我想要一个用户可以填写表格提出想法或错误的地方,但希望它看起来与游戏图形/按钮等的其余部分相似。我不知道如何制作带图片的自定义文本字段。我希望最终结果如下所示: 我知道如何设置自定
我的 Storyboard中有多个 UINavigationController。由于我使用的是 tabbarcontroller,因此每个选项卡项都在其 ViewController 之前嵌入了自己
我需要创建一个外观,将请求转发到其他 Web 服务。 除了转发之外,外观只会对用户进行身份验证/授权。 实现这个的好方法是什么? 我曾经使用 Jersey,也许有比手动创建 WebTarget 更好的
我使用了 windows 安装程序(msi 项目),实际上我在安装后得到了 msi 文件,它会在桌面上显示一个快捷方式。 我的问题是,当我双击我的应用程序的快捷方式时,它会显示类似安装的内容,然后它会
我通过 trayIcon.displayMessage(...) 在系统托盘上显示消息,但它们看起来不太好。我试图将它们的外观更改为系统标准,但在创建图标之前调用 UIManager.setLookA
我正在尝试为我的应用程序应用深色主题,当我调用深色主题时遇到问题,代码在重新启动应用程序之前不起作用。我在设置 View Controller 中使用 UISwtich 调用黑暗模式。当我打开深色模式
我正在为我不拥有或无法访问其源代码的 Swing 应用程序编写插件。在我的部分 UI 中,我想使用特定的颜色来匹配我的图标。 在这种情况下,我想创建一个具有特定背景颜色的 JPanel。 final
这个问题已经有答案了: 已关闭12 年前。 Possible Duplicate: Look and feel in java 是否有第三方漂亮的 L&F for Java swing 应用程序?默认
我想要 JButton 的外观: 我尝试通过这种方式更改 Windows 的外观: UIManager.setLookAndFeel("com.sun.java.swing.plaf.window
是否可以更改 UITabBarController 的外观? 例如,将 tabBarItems 垂直(而不是水平)排列在 View 的中心(而不是锁定在底部) 最佳答案 对于你想要的改变,没有。 您所
我是一名优秀的程序员,十分优秀!