当前位置: 首页>>代码示例>>C#>>正文


C# UISegmentedControl.AddTarget方法代码示例

本文整理汇总了C#中UISegmentedControl.AddTarget方法的典型用法代码示例。如果您正苦于以下问题:C# UISegmentedControl.AddTarget方法的具体用法?C# UISegmentedControl.AddTarget怎么用?C# UISegmentedControl.AddTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UISegmentedControl的用法示例。


在下文中一共展示了UISegmentedControl.AddTarget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCell

		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;
		}
开发者ID:ClusterReplyBUS,项目名称:MonoTouch.Dialog,代码行数:34,代码来源:TwoStateElement.cs

示例2: loadIPadLayout

 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);
     }
 }
开发者ID:nikolay-diyanov,项目名称:ios-sdk,代码行数:33,代码来源:ExampleViewController.cs

示例3: LoadView

        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;
            }*/
        }
开发者ID:skela,项目名称:GMGridView,代码行数:58,代码来源:DemoViewController.cs


注:本文中的UISegmentedControl.AddTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。