Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6390461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:33:04+00:00 2026-05-25T03:33:04+00:00

I have a problem using multiple UIBarButtonItem s within a UIToolbar on one side

  • 0

I have a problem using multiple UIBarButtonItems within a UIToolbar on one side of a UINavigationController. I‘ve used one of the many examples on how to put multiple buttons in the navigation bar (using a toolbar), and while I got it displaying correctly now, I always get an unkown Objective-C exception thrown when a button is pressed.

This is the full test UIViewController I use for adding multiple buttons:

using System;
using System.Drawing;
using MonoTouch.UIKit;

namespace TestProject
{
    public class Test : UIViewController
    {
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad();

            UIBarButtonItem btn1 = new UIBarButtonItem( "foo", UIBarButtonItemStyle.Bordered, delegate(object sender, EventArgs e) {
                Console.WriteLine( "asdf" );
            } );

            UIBarButtonItem btn2 = new UIBarButtonItem();
            btn2.Style = UIBarButtonItemStyle.Bordered;
            btn2.Title = "bar";
            btn2.Clicked += delegate(object sender, EventArgs e) {
                Console.WriteLine( "fdsa" );
            };

            UIToolbar tb = new UIToolbar( new RectangleF( 0, 0, 150, 44.0f ) );
            tb.SetItems( new UIBarButtonItem[] { btn1, btn2 }, false );
            NavigationItem.RightBarButtonItem = new UIBarButtonItem( tb );
        }
    }
}

I put that controller within a UINavigationController and display its view as the only window content. Everything works fine, until I click one of the buttons:

Error connecting stdout and stderr (127.0.0.1:10001)
Stacktrace:

  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:26
  at TestProject.Application.Main (string[]) [0x00000] in /Users/Apple/Projects/TestProject/TestProject/Main.cs:16
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

    0   TestProject                         0x000d0de8 mono_handle_native_sigsegv + 343
    1   TestProject                         0x0000f74c mono_sigsegv_signal_handler + 322
    2   libSystem.B.dylib                   0x906fc45b _sigtramp + 43
    3   ???                                 0xffffffff 0x0 + 4294967295
    4   UIKit                               0x01ee6cc3 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
    5   UIKit                               0x01cd44fd -[UIApplication sendAction:to:from:forEvent:] + 119
    6   UIKit                               0x01d64799 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x01d66c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    8   UIKit                               0x01d657d8 -[UIControl touchesEnded:withEvent:] + 458
    9   UIKit                               0x01cf8ded -[UIWindow _sendTouchesForEvent:] + 567
    10  UIKit                               0x01cd9c37 -[UIApplication sendEvent:] + 447
    11  UIKit                               0x01cdef2e _UIApplicationHandleEvent + 7576
    12  GraphicsServices                    0x0404f992 PurpleEventCallback + 1550
    13  CoreFoundation                      0x00ea2944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    14  CoreFoundation                      0x00e02cf7 __CFRunLoopDoSource1 + 215
    15  CoreFoundation                      0x00dfff83 __CFRunLoopRun + 979
    16  CoreFoundation                      0x00dff840 CFRunLoopRunSpecific + 208
    17  CoreFoundation                      0x00dff761 CFRunLoopRunInMode + 97
    18  GraphicsServices                    0x0404e1c4 GSEventRunModal + 217
    19  GraphicsServices                    0x0404e289 GSEventRun + 115
    20  UIKit                               0x01ce2c93 UIApplicationMain + 1160
    21  ???                                 0x077efe64 0x0 + 125763172
    22  ???                                 0x077ef1e2 0x0 + 125759970
    23  ???                                 0x077ef0be 0x0 + 125759678
    24  ???                                 0x077ef145 0x0 + 125759813
    25  TestProject                         0x0000f507 mono_jit_runtime_invoke + 1332
    26  TestProject                         0x001ed259 mono_runtime_invoke + 137
    27  TestProject                         0x001ef940 mono_runtime_exec_main + 669
    28  TestProject                         0x001eed2a mono_runtime_run_main + 843
    29  TestProject                         0x000a3093 mono_jit_exec + 200
    30  TestProject                         0x002a163d main + 4060
    31  TestProject                         0x00002819 _start + 208
    32  TestProject                         0x00002748 start + 40

Debug info from gdb:

dyld: could not load inserted library: /Users/Apple/Library/Application Support/iPhone Simulator/4.3/Applications/86C48AC1-821F-49DD-B344-58471F02D31B/TestProject.app/monotouch-fixes.dylib


=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Does anyone know what‘s causing this, and more importantly how to avoid it? When setting just a single button as the RightBarButtonItem it works without any problems.

edit

Above error seems to randomly cycle with this one:

Error connecting stdout and stderr (127.0.0.1:10001)
2011-08-25 13:30:05.409 TestProject[1235:a0b] -[__NSCFSet InvokeAction:]: unrecognized selector sent to instance 0x7168980

Unhandled Exception: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[__NSCFSet InvokeAction:]: unrecognized selector sent to instance 0x7168980
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:26 
  at TestProject.Application.Main (System.String[] args) [0x00000] in /Users/Apple/Projects/TestProject/TestProject/Main.cs:16 
[ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[__NSCFSet InvokeAction:]: unrecognized selector sent to instance 0x7168980
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/monotouch/UIKit/UIApplication.cs:26 
  at TestProject.Application.Main (System.String[] args) [0x00000] in /Users/Apple/Projects/TestProject/TestProject/Main.cs:16 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:33:04+00:00Added an answer on May 25, 2026 at 3:33 am

    Declare the buttons as class variables. The GC collects them so your event handlers are causing memory leaks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem using multiple (2) jQuery plugins. I've googled a little but
I have a problem when I try to persist objects using multiple threads .
I have the following problem using a has_many :through many-to-many relation in a multi-select
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have a problem using the Java search function in Eclipse on a particular
I have a problem using Linq to NHibernate to load an object and eagerly
I have a problem using the SSIS. I try to import data from database
I have a problem using JSON and arrays. Here is my code: while($row =
i have a problem using the Catch Clipboard Events code found on this link
Greetings, I have a problem using jqgrid and jquery tab (I am coding in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.