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


C# UITableView.IndexPathForCell方法代码示例

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


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

示例1: GetCell

        public override UITableViewCell GetCell(Cell item, UITableView tv)
        {
            var extendedCell = (ExtendedViewCell)item;
            var cell = base.GetCell (item, tv);
            if (cell != null) {
                cell.BackgroundColor = extendedCell.BackgroundColor.ToUIColor ();
                cell.SeparatorInset = new UIEdgeInsets ((float)extendedCell.SeparatorPadding.Top, (float)extendedCell.SeparatorPadding.Left,
                    (float)extendedCell.SeparatorPadding.Bottom, (float)extendedCell.SeparatorPadding.Right);

                if (extendedCell.ShowDisclousure) {
                    cell.Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator;
                    if (!string.IsNullOrEmpty (extendedCell.DisclousureImage)) {
                        var detailDisclosureButton = UIButton.FromType (UIButtonType.Custom);
                        detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Normal);
                        detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Selected);

                        detailDisclosureButton.Frame = new RectangleF (0f, 0f, 30f, 30f);
                        detailDisclosureButton.TouchUpInside += (object sender, EventArgs e) => {
                            var index = tv.IndexPathForCell (cell);
                            tv.SelectRow (index, true, UITableViewScrollPosition.None);
                            tv.Source.AccessoryButtonTapped (tv, index);
                        };
                        cell.AccessoryView = detailDisclosureButton;
                    }
                }
            }

            if(!extendedCell.ShowSeparator)
                tv.SeparatorStyle = UITableViewCellSeparatorStyle.None;

            tv.SeparatorColor = extendedCell.SeparatorColor.ToUIColor();

            return cell;
        }
开发者ID:khuatt,项目名称:Xamarin-Forms-Labs,代码行数:34,代码来源:ExtendedViewCellRenderer.cs

示例2: GetCell

        /// <summary>
        /// Gets the cell.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="reusableCell">The reusable TableView cell.</param>
        /// <param name="tv">The TableView.</param>
        /// <returns>UITableViewCell.</returns>
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
		{
			var extendedCell = (ExtendedTextCell)item;

			TextCell textCell = (TextCell)item;
			UITableViewCellStyle style = UITableViewCellStyle.Subtitle;
			if (extendedCell.DetailLocation == TextCellDetailLocation.Right)
				style = UITableViewCellStyle.Value1;

			string fullName = item.GetType ().FullName;
			CellTableViewCell cell = tv.DequeueReusableCell (fullName) as CellTableViewCell;
			if (cell == null) {
				cell = new CellTableViewCell (style, fullName);
			}
			else {
				cell.Cell.PropertyChanged -= new PropertyChangedEventHandler (cell.HandlePropertyChanged);
			}
			cell.Cell = textCell;
			textCell.PropertyChanged += new PropertyChangedEventHandler (cell.HandlePropertyChanged);
			cell.PropertyChanged = new Action<object, PropertyChangedEventArgs> (HandlePropertyChanged);
			cell.TextLabel.Text = textCell.Text;
			cell.DetailTextLabel.Text = textCell.Detail;
			cell.TextLabel.TextColor = textCell.TextColor.ToUIColor (DefaultTextColor);
			cell.DetailTextLabel.TextColor = textCell.DetailColor.ToUIColor (DefaultDetailColor);

			UpdateBackground (cell, item);

			if (cell != null) {
				cell.BackgroundColor = extendedCell.BackgroundColor.ToUIColor ();
				cell.SeparatorInset = new UIEdgeInsets ((float)extendedCell.SeparatorPadding.Top, (float)extendedCell.SeparatorPadding.Left,
					(float)extendedCell.SeparatorPadding.Bottom, (float)extendedCell.SeparatorPadding.Right);

				if (extendedCell.ShowDisclousure) {
					cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
					if (!string.IsNullOrEmpty (extendedCell.DisclousureImage)) {
						var detailDisclosureButton = UIButton.FromType (UIButtonType.Custom);
						detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Normal);
						detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Selected);

						detailDisclosureButton.Frame = new CGRect (0f, 0f, 30f, 30f);
						detailDisclosureButton.TouchUpInside += (object sender, EventArgs e) => {
							var index = tv.IndexPathForCell (cell);
							tv.SelectRow (index, true, UITableViewScrollPosition.None);
							tv.Source.AccessoryButtonTapped (tv, index);
						};
						cell.AccessoryView = detailDisclosureButton;
					}
				}
			}

			if(!extendedCell.ShowSeparator)
				tv.SeparatorStyle = UITableViewCellSeparatorStyle.None;

			tv.SeparatorColor = extendedCell.SeparatorColor.ToUIColor();

			return cell;
		}
开发者ID:nrogoff,项目名称:Xamarin-Forms-Labs,代码行数:64,代码来源:ExtendedTextCellRenderer.cs

示例3: WireUpForceUpdateSizeRequested

		protected void WireUpForceUpdateSizeRequested(ICellController cell, UITableViewCell nativeCell, UITableView tableView)
		{
			cell.ForceUpdateSizeRequested -= _onForceUpdateSizeRequested;

			_onForceUpdateSizeRequested = (sender, e) => 
			{
				var index = tableView.IndexPathForCell(nativeCell);
				if (index != null)
					tableView.ReloadRows(new[] { index }, UITableViewRowAnimation.None);
			};

			cell.ForceUpdateSizeRequested += _onForceUpdateSizeRequested;
		}
开发者ID:cosullivan,项目名称:Xamarin.Forms,代码行数:13,代码来源:CellRenderer.cs

示例4: GetCell

        /// <summary>
        /// Gets the cell.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="reusableCell">The reusable TableView cell.</param>
        /// <param name="tv">The TableView.</param>
        /// <returns>UITableViewCell.</returns>
        public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
        {
            var extendedCell = (ExtendedViewCell)item;
            var cell = base.GetCell(item, reusableCell,tv);
            if (cell != null) 
            {
                cell.BackgroundColor = extendedCell.BackgroundColor.ToUIColor();
                cell.SeparatorInset = new UIEdgeInsets(
                    (nfloat)extendedCell.SeparatorPadding.Top, 
                    (nfloat)extendedCell.SeparatorPadding.Left,
                    (nfloat)extendedCell.SeparatorPadding.Bottom, 
                    (nfloat)extendedCell.SeparatorPadding.Right);

                if (extendedCell.ShowDisclousure) 
                {
                    cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
                    if (!string.IsNullOrEmpty (extendedCell.DisclousureImage)) 
                    {
                        var detailDisclosureButton = UIButton.FromType (UIButtonType.Custom);
                        detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Normal);
                        detailDisclosureButton.SetImage (UIImage.FromBundle (extendedCell.DisclousureImage), UIControlState.Selected);

                        detailDisclosureButton.Frame = new CGRect (0f, 0f, 30f, 30f);
                        detailDisclosureButton.TouchUpInside += (sender, e) => 
                        {
                                try 
                                {
                                    var index = tv.IndexPathForCell (cell);
                                    tv.SelectRow (index, true, UITableViewScrollPosition.None);
                                    tv.Source.RowSelected (tv, index);
                                } 
                                catch (Foundation.You_Should_Not_Call_base_In_This_Method) 
                                {
                                    Console.Write("XLabs Weird stuff : You_Should_Not_Call_base_In_This_Method happend");
                                }
                        };
                        cell.AccessoryView = detailDisclosureButton;
                    }
                }
            }

            if (!extendedCell.ShowSeparator)
            {
                tv.SeparatorStyle = UITableViewCellSeparatorStyle.None;
            }   

            tv.SeparatorColor = extendedCell.SeparatorColor.ToUIColor();

            return cell;
        }
开发者ID:jdluzen,项目名称:Xamarin-Forms-Labs,代码行数:57,代码来源:ExtendedViewCellRenderer.cs

示例5: IndexPathForCell

 internal NSIndexPath IndexPathForCell(UITableView tableView, UITableViewCell cell)
 {
     if (ReferenceEquals(cell, _lastCreatedCell))
         return _lastCreatedCellPath;
     return tableView.IndexPathForCell(cell);
 }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:6,代码来源:TableViewSourceBase.cs

示例6: PrepareEntry

		protected virtual void PrepareEntry(UITableView tableview){
			SizeF size = _computeEntryPosition(tableview);
			
			_entry = new CustomTextField (new RectangleF (size.Width+10, (ContentView.Bounds.Height-size.Height)/2-10, 320-size.Width-20, size.Height+20));
			_delegate = new CustomTextFieldDelegate ();
			_entry.Delegate = _delegate;

			_entry.VerticalAlignment = UIControlContentVerticalAlignment.Center;

			TextLabel.BackgroundColor = UIColor.Clear;
			_entry.AutoresizingMask = UIViewAutoresizing.FlexibleWidth |
				UIViewAutoresizing.FlexibleLeftMargin;

			_entry.MaxCharacters = 5;

			_entry.Started += delegate {
				var position = tableview.IndexPathForCell(this);
				tableview.SelectRow(position, false, UITableViewScrollPosition.None);
			};

			_entry.ValueChanged += delegate {
				if (_element != null) {
					_element.Value = _entry.Text;
				}
			};
			_entry.EnablesReturnKeyAutomatically = true;
			_entry.Ended += (object sender, EventArgs e) => {
				if (_element != null) {
					_element.Value = _entry.Text;
					
					if (_element.OnValueChanged!=null)
						_element.OnValueChanged(_element);
				}
				
				var position = tableview.IndexPathForCell(this);
				if (tableview.IndexPathForSelectedRow!=null && position!=null && position.Compare(tableview.IndexPathForSelectedRow)==0){
					tableview.DeselectRow(position, false);
				}

			};
			_entry.ShouldChangeCharacters = (textField, range, replacement) => 
			{
				if (_element.MaxLength<0) return true;
				if (_element.MaxLength==0) return false;
				using (NSString original = new NSString(textField.Text))
				{
					var replace = original.Replace(range, new NSString(replacement));
					if (replace.Length>_element.MaxLength)
						return false;
				}
				return true;
			};

			_entry.AddTarget((object o, EventArgs r)=>{
				if (_element != null)
					_element.Value = _entry.Text;
				}, UIControlEvent.EditingChanged);
				
			_entry.ShouldReturn += delegate {
				Element elementToFocusOn = null;
				
				foreach (var c in ((Section)_element.Parent).Elements){
					if (c == _element)
						elementToFocusOn = c;
					else if (elementToFocusOn != null && c is EntryElement)
						elementToFocusOn = c as EntryElement;
				}
				if (elementToFocusOn != _element && elementToFocusOn!=null) {
					var cell = tableview.CellAt(elementToFocusOn.GetIndexPath());
					cell.BecomeFirstResponder();
				}
				else 
					_entry.ResignFirstResponder();

                if (_entry.ReturnKeyType == UIReturnKeyType.Go) {
                    _element.FireGo(this, EventArgs.Empty);
                }

				return true;
			};
			_entry.Started += delegate {
				EntryElement self = null;
				var returnType = _element.ReturnKeyType;

                if (returnType != UIReturnKeyType.Default) {
                    foreach (var e in (_element.Parent as Section).Elements){
                        if (e == _element)
                            self = _element;
                        else if (self != null && e is EntryElement)
                            returnType = UIReturnKeyType.Next;
                    }
                }
                _entry.ReturnKeyType = returnType;
			};
				
			ContentView.AddSubview (_entry);
		}
开发者ID:escoz,项目名称:MonoMobile.Forms,代码行数:97,代码来源:EntryElementCell.cs


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