本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: IndexPathForCell
internal NSIndexPath IndexPathForCell(UITableView tableView, UITableViewCell cell)
{
if (ReferenceEquals(cell, _lastCreatedCell))
return _lastCreatedCellPath;
return tableView.IndexPathForCell(cell);
}
示例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);
}