示例#1
0
        private void AddSearchButtonObserver(UISearchBar searchBar)
        {
            var controls = searchBar
                           .GetAllSubViews()
                           .OfType <UIControl>();

            foreach (var control in controls)
            {
                control.AddObserver(this,
                                    control.GetPropertyName(c => c.Enabled).ToLower(),
                                    NSKeyValueObservingOptions.New, IntPtr.Zero);
            }
        }
示例#2
0
        private void RemoveSearchButtonObserver(UISearchBar searchBar)
        {
            var controls = searchBar
                           .GetAllSubViews()
                           .OfType <UIControl>();

            foreach (var control in controls)
            {
                try
                {
                    control.RemoveObserver(this,
                                           control.GetPropertyName(c => c.Enabled).ToLower());
                }
                catch (MonoTouchException)
                {
                }
            }
        }
 /// <summary>
 /// Finds the Cancelbutton
 /// </summary>
 /// <returns></returns>
 public static UIButton GetCancelButton(this UISearchBar searchBar)
 {
     //Look for a button, probably only one button, and that is probably the cancel button.
     return(searchBar.GetAllSubViews().OfType <UIButton>().FirstOrDefault());
 }