c# - How Do I Add/Remove a UIBarButtonItem to/from a UIToolbar After Items Have Already Been Added? -


i working in xamarin.ios , have uitoolbar needs able add , remove buttons programmatically @ run-time.

i have tried several different approaches using: _buttons uibarbuttonitem[]

setitems(_buttons, false) 

and toolbar never seems update.

i initialize toolbar when app starts main 3 buttons. when things happen, need able remove buttons toolbar add new items toolbar.

i have tried calling:

setneedsdisplay() 

after calling:

setitems(_buttons, false) 

and doesn't update toolbar items either.

any suggestions?

and reason not changing because layoutsubviews called time , overrides setitems. use constructor populate toolbar first time

public partial class customuitoolbar : uitoolbar {     public customuitoolbar (intptr handle) : base (handle)     {         var _uibarbuttonitemarrayone = new uibarbuttonitem[3];         (int = 0; < 3; i++)         {             var _item = new uibarbuttonitem(i.tostring(), uibarbuttonitemstyle.done, null);             _item.tintcolor = uicolor.red;             _uibarbuttonitemarrayone[i] = _item;         }         //var __uibarbuttonitemarraytwo = new uibarbuttonitem[2];         //for (int = 0; < 2; i++)         //{         //    var _item = new uibarbuttonitem(i.tostring(), uibarbuttonitemstyle.done, null);         //    _item.tintcolor = uicolor.blue;         //    __uibarbuttonitemarraytwo[i] = _item;         //}         setitems(_uibarbuttonitemarrayone, true);     }      public override void layoutsubviews()     {         base.layoutsubviews();        } } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -