コード例 #1
0
		public override UITableViewCell GetCell (UITableView tv)
		{
			sc = new UISegmentedControl () {
				BackgroundColor = UIColor.Clear,
				Tag = 1,
			};
			sc.Selected = true;

			sc.InsertSegment (choices [0].Text, 0, false);
			sc.InsertSegment (choices [1].Text, 1, false);
			sc.Frame = new RectangleF (570f, 8f, 150f, 26f);

			sc.SelectedSegment = choices.FindIndex (e => e.Id == val.Id);
			sc.AddTarget (delegate {
				Value = choices [sc.SelectedSegment];
			}, UIControlEvent.ValueChanged);

			var cell = tv.DequeueReusableCell (CellKey);
//			if (cell == null) {
				cell = new UITableViewCell (UITableViewCellStyle.Default, CellKey);
				cell.SelectionStyle = UITableViewCellSelectionStyle.None;
				cell.AddSubview (sc);
//			} 
//			else
//				RemoveTag (cell, 1);
			cell.TextLabel.Font = UIFont.BoldSystemFontOfSize (17);
			//cell.Frame.Height = 44;
			cell.TextLabel.Text = Caption;
			if (this.IsMandatory)
				cell.TextLabel.Text += "*";
			

			return cell;
		}
コード例 #2
0
        void loadIPadLayout()
        {
            CGSize desiredSize = CGSize.Empty;

            if (sections.Count == 0 && options.Count == 1)
            {
                UIButton button = new UIButton(UIButtonType.RoundedRect);
                button.SetTitle(options [0].OptionText, UIControlState.Normal);
                button.AddTarget(optionTouched, UIControlEvent.TouchUpInside);
                desiredSize  = button.SizeThatFits(this.View.Bounds.Size);
                button.Frame = new CGRect(30, 10, desiredSize.Width, desiredSize.Height);
                this.View.AddSubview(button);
            }
            else if (options.Count >= 3 || sections.Count > 0)
            {
                settingsButton = new UIBarButtonItem(new UIImage("menu.png"), UIBarButtonItemStyle.Plain, settingsTouched);
                this.NavigationItem.RightBarButtonItem = settingsButton;
            }
            else
            {
                UISegmentedControl segmented = new UISegmentedControl();
                for (int i = 0; i < options.Count; i++)
                {
                    segmented.InsertSegment(options [i].OptionText, i + 1, false);
                }
                desiredSize     = segmented.SizeThatFits(this.View.Bounds.Size);
                segmented.Frame = new CGRect(10, 10, desiredSize.Width, desiredSize.Height);
                segmented.AddTarget(optionTouched, UIControlEvent.ValueChanged);
                this.View.AddSubview(segmented);
                segmented.SelectedSegment = this.SelectedOption;
            }
            exampleBounds = new CGRect(20, 30 + desiredSize.Height, this.View.Bounds.Size.Width - 40, this.View.Bounds.Size.Height - desiredSize.Height - 60);
        }
コード例 #3
0
 protected override void OnElementChanged(VisualElementChangedEventArgs e)
 {
     base.OnElementChanged(e);
     if (ViewController != null)
     {
         NSArray            items            = NSArray.FromStrings(new string[] { "Courses", "Favourite", "Recent" });
         UISegmentedControl segmentedControl = new UISegmentedControl(items)
         {
             Frame = new CGRect(50, 20, NativeView.Bounds.Width - 100, 35)
         };
         segmentedControl.SelectedSegment = 0;
         segmentedControl.TintColor       = UIColor.Red;
         segmentedControl.ApportionsSegmentWidthsByContent = true; //Change the width of the segment based on the content of the segment
         segmentedControl.AddTarget(this, new Selector("ValueChanged:"), UIControlEvent.ValueChanged);
         NativeView.AddSubview(segmentedControl);
     }
 }
コード例 #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var segmentTextContent = new string[]
            {
                NSBundle.MainBundle.GetLocalizedString("Image"),
                NSBundle.MainBundle.GetLocalizedString("Text"),
                NSBundle.MainBundle.GetLocalizedString("Video"),
            };

            // Segmented control as the custom title view
            var segmentedControl = new UISegmentedControl(segmentTextContent);

            segmentedControl.SelectedSegment  = 0;
            segmentedControl.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
            segmentedControl.Frame            = new CGRect(0f, 0f, 400f, 30f);
            segmentedControl.AddTarget(this.Action, UIControlEvent.ValueChanged);

            base.NavigationItem.TitleView = segmentedControl;
        }
コード例 #5
0
        /// <summary>
        /// Action for the segemented control.
        /// </summary>
        partial void ChangeRightBarItem(UISegmentedControl sender)
        {
            switch (sender.SelectedSegment)
            {
            case 0:
                // Add a custom add button as the nav bar's custom right view
                var addButton = new UIBarButtonItem(NSBundle.MainBundle.GetLocalizedString("AddTitle"),
                                                    UIBarButtonItemStyle.Plain,
                                                    this.Action);

                base.NavigationItem.RightBarButtonItem = addButton;
                break;

            case 1:
                // Add a custom add button as the nav bar's custom right view
                var emailButton = new UIBarButtonItem(UIImage.FromBundle("Email"),
                                                      UIBarButtonItemStyle.Plain,
                                                      this.Action);

                base.NavigationItem.RightBarButtonItem = emailButton;
                break;

            case 2:
                // "Segmented" control to the right
                var segmentedControl = new UISegmentedControl(new UIImage[] { UIImage.FromBundle("UpArrow"), UIImage.FromBundle("DownArrow") });

                segmentedControl.AddTarget(this.Action, UIControlEvent.ValueChanged);
                segmentedControl.Frame     = new CGRect(0f, 0f, 90f, 30f);
                segmentedControl.Momentary = true;

                // Add a custom add button as the nav bar's custom right view
                var segmentBarItem = new UIBarButtonItem(segmentedControl);

                base.NavigationItem.RightBarButtonItem = segmentBarItem;
                break;
            }
        }
コード例 #6
0
 void loadIPadLayout()
 {
     CGSize desiredSize = CGSize.Empty;
     this.offset = 0;
     if (sections.Count == 0 && options.Count == 1)
     {
         UIButton button = new UIButton (UIButtonType.RoundedRect);
         button.SetTitle (options [0].OptionText, UIControlState.Normal);
         button.AddTarget (optionTouched, UIControlEvent.TouchUpInside);
         desiredSize = button.SizeThatFits (this.View.Bounds.Size);
         button.Frame = new CGRect (30, 10 + this.headerHeight, desiredSize.Width, desiredSize.Height);
         this.View.AddSubview (button);
         this.offset = (float)(10 + desiredSize.Height + 10);
     }
     else if (options.Count >= 3 || sections.Count > 0)
     {
         settingsButton = new UIBarButtonItem (new UIImage ("menu.png"), UIBarButtonItemStyle.Plain, settingsTouched);
         this.NavigationItem.RightBarButtonItem = settingsButton;
     }
     else
     {
         UISegmentedControl segmented = new UISegmentedControl ();
         for (int i = 0; i < options.Count; i++) {
             segmented.InsertSegment (options [i].OptionText, i + 1, false);
         }
         desiredSize = segmented.SizeThatFits (this.View.Bounds.Size);
         segmented.Frame = new CGRect (10, 10 + this.headerHeight, desiredSize.Width, desiredSize.Height);
         segmented.AddTarget (optionTouched, UIControlEvent.ValueChanged);
         this.View.AddSubview (segmented);
         segmented.SelectedSegment = this.SelectedOption;
         this.offset = (float)(10 + desiredSize.Height + 10);
     }
 }
コード例 #7
0
        public override void LoadView()
        {
            base.LoadView ();

            View.BackgroundColor = UIColor.White;

            int spacing = GridViewConstants.IsIphone ? 10 : 15;

            GridView aGridView = new GridView(View.Bounds);
            aGridView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            aGridView.BackgroundColor = UIColor.Clear;
            demoGridView = aGridView;
            View.AddSubview(demoGridView);

            demoGridView.Style = GridViewStyle.Swap;
            demoGridView.ItemSpacing = spacing;
            demoGridView.MinEdgeInsets = new UIEdgeInsets(spacing, spacing, spacing, spacing);
            demoGridView.CenterGrid = true;
            demoGridView.ActionDelegate = this;
            demoGridView.SortingDelegate = this;
            demoGridView.TransformDelegate = this;
            demoGridView.DataSource = this;

            UIButton infoButton = new UIButton(UIButtonType.InfoDark);
            infoButton.Frame = new RectangleF(View.Bounds.Size.Width - 40,
                                              View.Bounds.Size.Height - 40,
                                          40,
                                          40);
            infoButton.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleTopMargin;
            infoButton.AddTarget(this,new Selector("presentInfo"),UIControlEvent.TouchUpInside);
            View.AddSubview(infoButton);

            UISegmentedControl dataSegmentedControl = new UISegmentedControl(new String[]{"DataSet 1","DataSet 2"});
            dataSegmentedControl.SizeToFit();

            dataSegmentedControl.Frame = new RectangleF(5,
                                                        View.Bounds.Size.Height - dataSegmentedControl.Bounds.Size.Height - 5,
                                                        dataSegmentedControl.Bounds.Size.Width,
                                                        dataSegmentedControl.Bounds.Size.Height);
            dataSegmentedControl.AutoresizingMask = UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleTopMargin;
            dataSegmentedControl.TintColor = UIColor.Green;
            dataSegmentedControl.SelectedSegment = 0;
            dataSegmentedControl.AddTarget(this,new Selector("dataSetChange:"),UIControlEvent.ValueChanged);
            View.AddSubview(dataSegmentedControl);

            /*
            OptionsViewController *optionsController = [[OptionsViewController alloc] init];
            optionsController.gridView = gmGridView;
            optionsController.contentSizeForViewInPopover = CGSizeMake(400, 500);

            _optionsNav = [[UINavigationController alloc] initWithRootViewController:optionsController];

            if (INTERFACE_IS_PHONE)
            {
                UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(optionsDoneAction)];
                optionsController.navigationItem.rightBarButtonItem = doneButton;
            }*/
        }