{"id":4745,"date":"2014-03-30T15:02:58","date_gmt":"2014-03-30T15:02:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/uisegmentedcontrol-no-events-fire-when-used-in-uitoolbar-collection-of-common-programming-errors\/"},"modified":"2014-03-30T15:02:58","modified_gmt":"2014-03-30T15:02:58","slug":"uisegmentedcontrol-no-events-fire-when-used-in-uitoolbar-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/uisegmentedcontrol-no-events-fire-when-used-in-uitoolbar-collection-of-common-programming-errors\/","title":{"rendered":"UISegmentedControl: no events fire when used in UIToolbar-Collection of common programming errors"},"content":{"rendered":"<p>Monotouch 4.2 beta.<\/p>\n<p>I&#8217;m adding a <code>UISegmentedControl<\/code> to a <code>UIToolbar<\/code>. The problem is that none of the events fire when switching segments. What am I missing here?<\/p>\n<pre><code>this.oBookmarkSwitch = new UISegmentedControl(new UIImage[] { UIImage.FromFile(\".\/images\/index.png\"), UIImage.FromFile(\".\/images\/bookmark_grey.png\") });\nthis.oBookmarkSwitch.TouchUpInside += delegate {\nConsole.WriteLine(\"TOUCHY - never fires\");\n};\nthis.oBookmarkSwitch.ValueChanged += delegate {\nConsole.WriteLine(\"CHANGE - only fires once when the control is created\");\n};\nthis.oBookmarkSwitch.Frame = new RectangleF(0, 0, 100, 30);\nthis.oBookmarkSwitch.ControlStyle = UISegmentedControlStyle.Bar;\naBarButtons.Add(new UIBarButtonItem(this.oBookmarkSwitch));\noIndexToolbar.SetItems (aBarButtons.ToArray (), false);\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Monotouch 4.2 beta. I&#8217;m adding a UISegmentedControl to a UIToolbar. The problem is that none of the events fire when switching segments. What am I missing here? this.oBookmarkSwitch = new UISegmentedControl(new UIImage[] { UIImage.FromFile(&#8220;.\/images\/index.png&#8221;), UIImage.FromFile(&#8220;.\/images\/bookmark_grey.png&#8221;) }); this.oBookmarkSwitch.TouchUpInside += delegate { Console.WriteLine(&#8220;TOUCHY &#8211; never fires&#8221;); }; this.oBookmarkSwitch.ValueChanged += delegate { Console.WriteLine(&#8220;CHANGE &#8211; only fires once when [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4745","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4745"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4745\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}