本文整理汇总了C#中UITableView.SelectRow方法的典型用法代码示例。如果您正苦于以下问题:C# UITableView.SelectRow方法的具体用法?C# UITableView.SelectRow怎么用?C# UITableView.SelectRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UITableView
的用法示例。
在下文中一共展示了UITableView.SelectRow方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
table = new UITableView (this.View.Bounds);
table.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
table.RegisterClassForCellReuse (typeof(UITableViewCell), new NSString("cell"));
table.DataSource = new TableDataSource (example);
table.Delegate = new TableDelegate (example);
table.AllowsMultipleSelection = true;
table.BackgroundColor = UIColor.White;
this.View.AddSubview (table);
table.SelectRow (NSIndexPath.FromRowSection (example.SelectedTrendLine, 0), false, UITableViewScrollPosition.None);
table.SelectRow (NSIndexPath.FromRowSection (example.SelectedIndicator, 1), false, UITableViewScrollPosition.None);
}
示例3: 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;
}
示例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: ViewDidLoad
public override void ViewDidLoad()
{
MonthView = new CalendarMonthView();
MonthView.Frame = new System.Drawing.RectangleF(new PointF(0,152), MonthView.Frame.Size);
ChangedSelecting();
View.AddSubview(MonthView);
TableView = new UITableView(new RectangleF(0,0,320,150), UITableViewStyle.Grouped);
TableView.DataSource = new DateSource(this);
TableView.Delegate = new DateDelegate(this);
TableView.SelectRow(NSIndexPath.FromRowSection(0,0), true, UITableViewScrollPosition.Top);
this.View.AddSubview(TableView);
}
示例6: GetCell
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
var cell = tableView.DequeueReusableCell (cellId);
if (cell == null) {
cell = new UITableViewCell (UITableViewCellStyle.Default, cellId);
}
cell.TextLabel.Text = items [indexPath.Row].Title;
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
cell.TextLabel.Font = UIFont.FromName ("Helvetica-Bold", 14f);
setCell (cell, indexPath);
if (items [indexPath.Row].Selected) {
// i think this doesnt call RowSelected so we're cool
tableView.SelectRow (indexPath, false, UITableViewScrollPosition.None);
}
return cell;
}
示例7: SetSelectedCellByItem
protected override void SetSelectedCellByItem(UITableView tableView, object selectedItem)
{
if (selectedItem == null)
ClearSelection(tableView);
else
{
int i = ItemsSource.IndexOf(selectedItem);
ClearSelection(tableView);
if (i >= 0)
{
var indexPath = NSIndexPath.FromRowSection(i, 0);
tableView.SelectRow(indexPath, UseAnimations, ScrollPosition);
RowSelected(tableView, indexPath);
}
}
}
示例8: Configure
public static void Configure(UITableView tableView, string [] choices)
{
tableView.DataSource = new StringDataSource (tableView, choices);
tableView.Delegate = new StringDelegate ();
tableView.SelectRow (NSIndexPath.FromRowSection (0, 0), true, UITableViewScrollPosition.None);
}
示例9: BeginEditing
public void BeginEditing(UITableView tableView)
{
// Select all.
for (int i = 0; i < shownCourses.Count; i++)
tableView.SelectRow(NSIndexPath.FromRowSection((nint)i, 0), true, UITableViewScrollPosition.None);
var hidden = HiddenPaths();
tableView.BeginUpdates();
tableView.InsertRows(hidden, UITableViewRowAnimation.Top);
shownCourses = courses;
tableView.EndUpdates();
}
示例10: GetCell
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
object item = GetItemAt(indexPath);
var selector = _templateProvider.TableCellTemplateSelector;
if (selector == null)
throw new NotSupportedException("The ItemTemplate is null to create UITableViewCell use the ItemTemplate with ITableCellTemplateSelector value.");
UITableViewCell cell;
if (selector is ITableCellTemplateSelectorSupportDequeueReusableCell)
cell = ((ITableCellTemplateSelectorSupportDequeueReusableCell)selector).DequeueReusableCell(tableView, item, indexPath);
else
cell = tableView.DequeueReusableCell(selector.GetIdentifier(item, tableView), indexPath);
_lastCreatedCell = cell;
_lastCreatedCellPath = indexPath;
if (Equals(item, _selectedItem) && !cell.Selected)
tableView.SelectRow(indexPath, false, UITableViewScrollPosition.None);
cell.Tag |= InitializingStateMask;
cell.SetDataContext(item);
if (!HasMask(cell, InitializedStateMask))
{
cell.Tag |= InitializedStateMask;
ParentObserver.GetOrAdd(cell).Parent = tableView;
selector.InitializeTemplate(tableView, cell);
}
cell.Tag &= ~InitializingStateMask;
(cell as IHasDisplayCallback)?.WillDisplay();
return cell;
}
示例11: Selected
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
tableView.SelectRow(path, false, UITableViewScrollPosition.None);
((EntryElementCell)tableView.CellAt(path)).BecomeFirstResponder();
}
示例12: ViewDidLoad
public override void ViewDidLoad ()
{
this.View.BackgroundColor = UIColor.White;
menuVisible = false;
nfloat height = this.View.Bounds.Height - 64 - 49;
nfloat left = this.View.Bounds.Width - 260;
menuView = new UIView(new CGRect( left, 64, 260, height));
menuTable = new UITableView (new CGRect (0, 0, 260, height));
menuTable.Layer.BorderWidth = 0.5f;
menuTable.Layer.BorderColor = (UIColor.FromRGBA (0.537f, 0.537f, 0.537f, 0.5f)).CGColor;
menuTable.BackgroundColor = UIColor.White;
menuTable.Source = new sampleDataSource (this) ;
NSIndexPath indexPath = NSIndexPath.FromRowSection (0, 0);
menuTable.SelectRow (indexPath, false, UITableViewScrollPosition.Top);
menuView.AddSubview (menuTable);
fadeOutView = new UIView(this.View.Bounds);
fadeOutView.BackgroundColor = UIColor.FromRGBA( 0.537f ,0.537f,0.537f,0.3f);
menuButton = new UIBarButtonItem();
menuButton.Image = UIImage.FromBundle ("Images/menu");
menuButton.Style = UIBarButtonItemStyle.Plain;
menuButton.Target = this;
menuButton.Clicked += OpenMenu;
optionButton = new UIBarButtonItem ();
optionButton.Image = UIImage.FromBundle ("Images/Option");
optionButton.Style = UIBarButtonItemStyle.Plain;
optionButton.Target = this;
optionButton.Clicked += OpenOptionView;
UITapGestureRecognizer singleFingerTap = new UITapGestureRecognizer ();
singleFingerTap.AddTarget(() => HandleSingleTap(singleFingerTap));
fadeOutView.AddGestureRecognizer (singleFingerTap);
selectedSample = sampleArray.GetItem<NSString> (0);
this.LoadSample (selectedSample);
this.NavigationController.InteractivePopGestureRecognizer.Enabled = false;
}
示例13: Selected
//INFO:
//http://monotouch.2284126.n4.nabble.com/How-to-keep-selected-element-row-highlighted-td4655163.html
public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath indexPath)
{
// dostuff
//tableView.DeselectRow (indexPath, true);
tableView.SelectRow(indexPath,true,UITableViewScrollPosition.None);
}
示例14: 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);
}