设置多个 UIBarButtonItems 在设备上失败,但在模拟器上失败
当我尝试在 MonoTouch 中设置多个 UIBarButtonItems 时,我始终遇到无效选择器异常。
在模拟器中,完全没有问题。我添加的每个按钮都可以正常工作。仅当我部署到测试设备(安装了 iOS 4.2.1 的 iPhone 3G)时,它才会抛出此错误:
-[UINavigationItem setRightBarButtonItems:animated:]: 无法识别的选择器发送到实例 0xef7af0
我尝试使用 RightBarButtonItems 属性和显式 SetRightBarButtonItems方法,在每种情况下传递一个 UIBarButtonItem[] 实例。
也许解决这个问题的方法是使用带有自定义视图的工具栏,但我宁愿只使用广告中的 API,特别是如果它在模拟器中正常工作的话。
有人遇到过这个吗?
I'm consistently running into an invalid selector exception when I attempt to set multiple UIBarButtonItems in MonoTouch.
In the simulator, there are no issues at all. Each button I add works correctly. Only when I deploy to a test device (iPhone 3G with iOS 4.2.1 installed) does it throw this error:
-[UINavigationItem setRightBarButtonItems:animated:]: unrecognized selector sent to instance 0xef7af0
I have tried using the RightBarButtonItems property and the explicit SetRightBarButtonItems method, passing a UIBarButtonItem[] instance in each case.
Maybe the way to get around this is to use a ToolBar with a custom view, but I'd rather just use the API as advertised, especially if it works correctly in the simulator.
Anyone run into this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您使用的是 MonoTouch 5.0 和最新的 iOS SDK (5) 和 Xcode 4.2。
setRightBarButtonItems:animated:
选择器是 iOS5 中的新选择器。这意味着它可以在模拟器中运行,模拟器可能默认为 5.0。然而,这在旧版本的 iOS 中不起作用(例如 4.2.1)。在这个阶段你有两个选择:
避免 iOS5 功能;或
在运行时检测正在使用的 iOS 版本,并将您的应用程序调整为可用的版本。
I assume you're using MonoTouch 5.0 and the latest iOS SDK (5) and Xcode 4.2.
The
setRightBarButtonItems:animated:
selector is new in iOS5. This means it will work in the simulator, which likely defaults to 5.0. However this won't work in older releases of iOS (e.g. like 4.2.1).At this stage you have two choices:
avoid iOS5 features; or
detect, at runtime, which version of iOS is being used and adjust your application to what's available.
看看这个:http://osmorphis.blogspot.com /2009/05/multiple-buttons-on-navigation-bar.html
如果你想为 iOS 添加多个右键< /2009/05/multiple-buttons-on-navigation-bar.html 它可以工作。 5.0
Check this out: http://osmorphis.blogspot.com/2009/05/multiple-buttons-on-navigation-bar.html
It works if you want to add multiple right buttons for iOS < 5.0