Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

"touchupinside unrecognized selector sent to instance"

When I click a button on my application I get the error:
touchupinside unrecognized selector sent to instance

It is discussed in this thread here: https://forums.xamarin.com/discussion/10734/hello-world-sad-world

I don't really understand what their solution is. So could someone explain it to me in a more detailed fashion?

Here is my code:

public partial class MainViewController : UIViewController
    {
        UIViewController byTopicVC;

        public MainViewController (IntPtr handle) : base (handle)
        {
        }

        public override void DidReceiveMemoryWarning ()
        {
            // Releases the view if it doesn't have a superview.
            base.DidReceiveMemoryWarning ();

            // Release any cached data, images, etc that aren't in use.
        }

        #region View lifecycle

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();

            // Perform any additional setup after loading the view, typically from a nib.
        }

        public override void ViewWillAppear (bool animated)
        {
            base.ViewWillAppear (animated);


        }

        public override void AwakeFromNib ()
        {
            // Called when loaded from xib or storyboard.

            this.Initialize();
        }

        public void Initialize(){


        }

        public override void ViewDidAppear (bool animated)
        {
            base.ViewDidAppear (animated);
            var myStoryboard = AppDelegate.Storyboard;
            //Instatiating View Controller with Storyboard ID 'PinkViewController'

            ByTopicButton.TouchUpInside += ByTopicButtonClick;
            VerseOfTheDayButton.TouchUpInside += VerseOfTheDayButtonClick;
            RequestVerseButton.TouchUpInside += RequestVerseButtonClick;
            MyVersesButton.TouchUpInside += MyVersesButtonClick;
            UpdateVersesButton.TouchUpInside += UpdateVersesButtonClick;
            MoreBibleVersionsButton.TouchUpInside += MoreBibleVersionsButtonClick;
            ByReferenceButton.TouchUpInside += ByReferenceButtonClick;

            byTopicVC = myStoryboard.InstantiateViewController ("ByTopicVC") as ByTopicVC;
        }

        public override void ViewWillDisappear (bool animated)
        {
            base.ViewWillDisappear (animated);
        }

        public override void ViewDidDisappear (bool animated)
        {
            base.ViewDidDisappear (animated);
        }

        #endregion

        void ByReferenceButtonClick (object sender, EventArgs ea) {
            //new UIAlertView("Alert Title", "Alert Text", null, "OK", null).Show();
            ByReferenceButton.SetBackgroundImage (UIImage.FromBundle ("buttonpress.png"), UIControlState.Normal);
        }

        void ByTopicButtonClick (object sender, EventArgs ea) {
            ByTopicButton.SetBackgroundImage (UIImage.FromBundle ("buttonpress.png"), UIControlState.Normal);
            this.NavigationController.PushViewController (byTopicVC, true);
        }

        void VerseOfTheDayButtonClick (object sender, EventArgs ea) {
            VerseOfTheDayButton.SetBackgroundImage (UIImage.FromBundle ("buttonpress.png"), UIControlState.Normal);
        }

        void RequestVerseButtonClick (object sender, EventArgs ea) {
            RequestVerseButton.SetBackgroundImage (UIImage.FromBundle ("buttonpress.png"), UIControlState.Normal);
        }

        void MyVersesButtonClick (object sender, EventArgs ea) {
            MyVersesButton.SetBackgroundImage (UIImage.FromBundle ("buttonpress.png"), UIControlState.Normal);
        }

        void UpdateVersesButtonClick (object sender, EventArgs ea) {
            UpdateVersesButton.SetBackgroundImage (UIImage.FromBundle ("buttonpress.png"), UIControlState.Normal);
        }

        void MoreBibleVersionsButtonClick (object sender, EventArgs ea) {
            MoreBibleVersionsButton.SetBackgroundImage (UIImage.FromBundle ("buttonpress.png"), UIControlState.Normal);
        }

    }

[Register ("MainViewController")]
    partial class MainViewController
    {
        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIButton ByReferenceButton { get; set; }

        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIButton ByTopicButton { get; set; }

        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIButton MoreBibleVersionsButton { get; set; }

        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIButton MyVersesButton { get; set; }

        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIButton RequestVerseButton { get; set; }

        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIImageView TopRedBar { get; set; }

        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIButton UpdateVersesButton { get; set; }

        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIButton VerseOfTheDayButton { get; set; }

        [Action ("ByTopicButton_TouchUpInside:")]
        [GeneratedCode ("iOS Designer", "1.0")]
        partial void ByTopicButton_TouchUpInside (UIButton sender);

        void ReleaseDesignerOutlets ()
        {
            if (ByReferenceButton != null) {
                ByReferenceButton.Dispose ();
                ByReferenceButton = null;
            }
            if (ByTopicButton != null) {
                ByTopicButton.Dispose ();
                ByTopicButton = null;
            }
            if (MoreBibleVersionsButton != null) {
                MoreBibleVersionsButton.Dispose ();
                MoreBibleVersionsButton = null;
            }
            if (MyVersesButton != null) {
                MyVersesButton.Dispose ();
                MyVersesButton = null;
            }
            if (RequestVerseButton != null) {
                RequestVerseButton.Dispose ();
                RequestVerseButton = null;
            }
            if (TopRedBar != null) {
                TopRedBar.Dispose ();
                TopRedBar = null;
            }
            if (UpdateVersesButton != null) {
                UpdateVersesButton.Dispose ();
                UpdateVersesButton = null;
            }
            if (VerseOfTheDayButton != null) {
                VerseOfTheDayButton.Dispose ();
                VerseOfTheDayButton = null;
            }
        }
    }

Posts

  • Ranjeet_SinghRanjeet_Singh INMember ✭✭

    To avoid this type of error you need to follow these steps:
    1) Un-Install existing app from the device you want to install.
    2) Clean your project and then install your app on the device.
    3) Make sure you have to implement all the events binds with any UIControl.

  • Ranjeet_SinghRanjeet_Singh INMember ✭✭

    To avoid this type of error you need to follow these steps:
    1) Un-Install existing app from the device you want to install.
    2) Clean your project and then install your app on the device.
    3) Make sure you have to implement all the events binds with any UIControl.

Sign In or Register to comment.