UIButtonBarItem issue with image type

Hello. I have thi piece of code to add buttons to bottom toolbar:

stopButton = new UIBarButtonItem (UIImage.FromBundle ("9_av_play.png"), (o, e) => { Console.WriteLine("stop clicked"); });
playButton = new UIBarButtonItem (UIImage.FromBundle ("9_av_play.png"), (o, e) => { Console.WriteLine("play clicked"); });
pauseButton = new UIBarButtonItem (UIImage.FromBundle ("9_av_pause.png"), (o, e) => { Console.WriteLine("pause clicked"); });
snapButton = new UIBarButtonItem (UIImage.FromBundle ("10_device_access_alarm.png"), (o, e) => { Console.WriteLine("take snapshot clicked"); });
infoButton = new UIBarButtonItem (UIImage.FromBundle ("2_action_about.png"), (o, e) => { Console.WriteLine("take snapshot clicked"); });        

this.SetToolbarItems(new UIBarButtonItem[] {stopButton,playButton,pauseButton,snapButton,infoButton},false);
this.NavigationController.ToolbarHidden = false;

But compiler breack with this error:
Error CS1502: The best overloaded method match for `MonoTouch.UIKit.UIBarButtonItem.UIBarButtonItem(MonoTouch.UIKit.UIBarButtonSystemItem, System.EventHandler)' has some invalid arguments (CS1502)
I have seen some samples and they are using UUimage.FromBoundle to load custom image for Toolbars. Where do I'm wrong ?
Please give me an hint.
Max

Posts

  • DaveHuntDaveHunt USMember ✭✭✭✭✭

    There is no UIBarButtonItem constructor that takes just a UIImage and an EventHandler. There is one that takes a UIImage, a UIBarButtonItemStyle, and an EventHandler.

    You need to specify a UIBarButtonItemStyle value between the UIImage and EventHandler parameters.

  • Yes, thanks.
    I have already seen my mistake.
    Sorry for rumors...

Sign In or Register to comment.