c# - 无法在 MonoTouch 中的 NavigationItem.RightBarButtonItems 中放置两个按钮

标签 c# iphone ios xamarin.ios uibarbuttonitem

在我的项目中,我需要将两个 UIBarButtonItem 添加到 View Controller 的 NavigationItem 中。我用这段代码解决了这个问题:

UIBarButtonItem saveButton = new UIBarButtonItem("Save", UIBarButtonItemStyle.Bordered, (sender, e) => {
    //some saving code...
    });
    UIBarButtonItem delButton = new UIBarButtonItem("Delete", UIBarButtonItemStyle.Done, (sender, e) => {
    //some deletion code...
    });
    UIBarButtonItem[] items = new UIBarButtonItem[]
    {
        saveButton,
        delButton
    };
    this.NavigationItem.RightBarButtonItems = items;

它在以前版本的 MonoTouch 中工作(在 iOS 5 上,包括设备和模拟器),但是(我认为是这样)在我升级到 MonoTouch 6 后,只显示数组中的第一个按钮。 我尝试使用 NavigationItem.SetRightBarButtonItems(items, false) 方法,但没有任何效果。

这是一个常见问题还是我做错了什么?

最佳答案

Is it a common problem or I am doing something wrong?

Touch.Unit,MonoTouch 的单元测试运行程序,使用 RightBarButtonItems 并与 MonoTouch 6.0.x 一起正常工作(显示两个按钮)。

OTOH 我发现您的代码片段没有任何问题(但它很短)。您最好的选择是创建一个小型、独立的应用程序来显示您的问题并将其附加到 bug report 。我们将能够对其进行审查并查看问题所在(或者您可能会在执行测试用例时自己发现问题,如果问题在您自己的代码中)。

关于c# - 无法在 MonoTouch 中的 NavigationItem.RightBarButtonItems 中放置两个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13160815/

相关文章:

c# - 为什么 HashAlgorithm 类要实现 IDisposable?

c# - 以编程方式创建的 UpdatePanel 扩展以填充父容器的最佳实践?

iphone - 在未来的应用程序版本中维护核心数据

iphone - iOS 蓝牙低功耗信号在后台发送

android - 如何在 React Native 中实现类似 snapchat 的圆形动画倒计时组件?

ios - 希望 TabBar 隐藏在页面 View Controller 的几个 Controller 中

从 Web 服务引用的 C# 类未正确反序列化

c# - 寻找花式窗体

iPhone UIWebView - 可以在输入文本字段上关闭自动完成功能吗?

iphone - 将简单 UIButton 子类化为复选框