I tried your code and did not have the problem you mentioned.  Your
bug may be in your xib file.  I did not use an xib for my testing.

For my AppDelegate this is my FinishedLaunching code...

public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
        window = new UIWindow (UIScreen.MainScreen.Bounds);
        
        viewController = new FirstAttempt.TableMainController ();
        navCtrl = new UINavigationController (viewController);
        window.RootViewController = navCtrl;
        window.MakeKeyAndVisible ();
        
        return true;
}

and I changed the ViewDidLoad to instantiate the Table View

public override void ViewDidLoad ()
{
        base.ViewDidLoad ();
        
        MainTableVIew = new UITableView (this.View.Bounds);
        MainTableVIew.AutoresizingMask = UIViewAutoresizing.All;
        this.View.AddSubview (MainTableVIew);

...

Finally I changed the ctor to call the default base ctor.

public TableMainController () : base () ...

-bill

On Mon, May 14, 2012 at 4:20 PM, celticfrost <[email protected]> wrote:
> Hello,
>
> Have spent countless hours but can't figure out why a simple piece of code
> is not working.
>
> I have a UIViewController that has a tableview.
>
> I have added Edit on the navigation bar but it doesn't seem to fire for some
> reason.
>
> At class-level I have a variable:
> UIBarButtonItem buttonEdit;
>
> Then in ViewDidLoad, I have
> this.NavigationController.NavigationBarHidden = false;
> this.buttonEdit = new UIBarButtonItem("Edit",UIBarButtonItemStyle.Bordered,
> this.ButtonEdit_Clicked);
> this.NavigationItem.HidesBackButton = true;
> this.NavigationItem.SetRightBarButtonItem (this.buttonEdit, true);
>
> And an event handler for Edit button:
> public void ButtonEdit_Clicked(object sender, EventArgs e)
> {
>        this.MainTableVIew.SetEditing (true, true);
>        this.NavigationItem.SetRightBarButtonItem (this.buttonDone, true);
>        this.NavigationItem.SetLeftBarButtonItem (this.buttonAdd, true);
> }
>
> Can anyone explain why Edit button is not firing and any work round.
>
> I have attached the full source code to the postcode.
>
>
> --
> View this message in context: 
> http://monotouch.2284126.n4.nabble.com/UIBarButtonItems-are-not-firing-in-UIViewController-tp4633026.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to