Xamarin.ios NavigationItem.SetRightBarButtonims引发异常

Xamarin.ios NavigationItem.SetRightBarButtonims引发异常,xamarin.ios,uinavigationbar,uinavigationitem,Xamarin.ios,Uinavigationbar,Uinavigationitem,如果我只在导航栏上设置了一个右键,它就可以完美地工作。 但当我试图设置多个按钮时,它们出现了,但单击它们会抛出异常 EventHandler pickPhotoClickHandler = (s,e) => {}; //Do nothing var pickPhotoBtn = new UIBarButtonItem(UIBarButtonSystemItem.Camera, pickPhotoClickHandler); EventHandler sendBtnClickHandler

如果我只在导航栏上设置了一个右键,它就可以完美地工作。 但当我试图设置多个按钮时,它们出现了,但单击它们会抛出异常

EventHandler pickPhotoClickHandler = (s,e) => {}; //Do nothing
var pickPhotoBtn = new UIBarButtonItem(UIBarButtonSystemItem.Camera, pickPhotoClickHandler);

EventHandler sendBtnClickHandler = (s, e) => {}; //Do nothing
var sendBtn = new UIBarButtonItem (UIBarButtonSystemItem.Done, sendBtnClickHandler);

NavigationItem.SetRightBarButtonItem (pickPhotoBtn, animated:true); // This works

var btns = new UIBarButtonItem[]{sendBtn,pickPhotoBtn}; // This doesn't 
NavigationItem.SetRightBarButtonItems(btns,true);       // go very far

我做错了什么?

我通过创建从
UIbarButtonItem
派生的新类并用IntPtr定义构造函数,成功地解决了这个问题

public class UIBarBtn : UIBarButtonItem{
        public UIBarBtn(IntPtr handle):base(handle){}
        public UIBarBtn(UIBarButtonSystemItem si, EventHandler handler):base(si,handler){}
}

现在它工作了

我通过创建从
UIbarButtonItem
派生的新类并用IntPtr定义构造函数,成功地解决了这个问题

public class UIBarBtn : UIBarButtonItem{
        public UIBarBtn(IntPtr handle):base(handle){}
        public UIBarBtn(UIBarButtonSystemItem si, EventHandler handler):base(si,handler){}
}
现在它工作了

请查看以下内容:

如果您想为iOS<5.0添加多个右键,则此功能有效

经过考验!:D

请查看以下内容:

如果您想为iOS<5.0添加多个右键,则此功能有效


经过考验!:D

有趣-我不认为导航栏支持屏幕上的多个按钮right@Jason:这是iOS 5.0中引入的新功能(我在尝试在4.3应用程序中使用它时发现了)。有趣的是,我不认为导航栏支持屏幕上的多个按钮right@Jason:这是iOS 5.0中引入的新功能(当我尝试在4.3应用程序中使用它时,我发现了这一点)。