テーブルセルをクリックすると、セグを使用して新しいページに移動したいと思います。しかし、私がセルをクリックするたびに何も起こりません。iOSテーブルセルの新しいビューへの移動Segueを使用してクリック
PrepareForSegueメソッドにブレークポイントを配置すると、DayTableViewのセルをクリックすると決してヒットしません。
DayTableViewController
namespace HHGoals2
{
public partial class DayTableViewController : UITableViewController
{
HHGoals2DataService dataService = new HHGoals2DataService();
public DayTableViewController(IntPtr handle) : base (handle)
{
}
public override void ViewDidLoad()
{
var allDays = dataService.GetAllDays();
var dataSource = new GoalsDataSource(allDays, this);
TableView.Source = dataSource;
this.NavigationItem.Title = "Completed Goals";
}
public override void PrepareForSegue (UIStoryboardSegue segue, NSObject sender)
{
base.PrepareForSegue(segue, sender);
if(segue.Identifier == "GoalDetailSegue")
{
var goalDetailViewController = segue.DestinationViewController
as GoalDetailViewController;
if(goalDetailViewController != null)
{
var source = TableView.Source as GoalsDataSource;
var rowPath = TableView.IndexPathForSelectedRow;
var item = source.GetItem(rowPath.Row);
goalDetailViewController.SelectedDay = item;
}
}
}
}
}
GoalsDataSource
using System;
using Foundation;
using UIKit;
using System.Collections.Generic;
using HHGoals2.Core.Model;
using HHGoals2.Cells;
namespace HHGoals2.DataSources
{
public class GoalsDataSource: UITableViewSource
{
private List<Day> allDays;
NSString cellIdentifier = new NSString("DayCell");
DayTableViewController callingController;
public GoalsDataSource(List<Day> allDays, DayTableViewController callingController)
{
this.allDays = allDays;
this.callingController = callingController;
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
DayListCell cell = tableView.DequeueReusableCell(cellIdentifier) as DayListCell;
if (cell == null)
{
cell = new DayListCell(cellIdentifier);
}
cell.UpdateCell(allDays[indexPath.Row].Number.ToString(),
allDays[indexPath.Row].SuccessRate.ToString(),
allDays[indexPath.Row].FailRate.ToString());
return cell;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
return allDays.Count;
}
public Day GetItem(int id)
{
return allDays[id];
}
}
}
私はDayCellのTouchUpInsideイベントを追加する必要がありますか?どのようにこれを動作させるための任意の提案は素晴らしいだろう。
[彼の答え](https://stackoverflow.com/questions/22759167/how-to-make-a-push-segue-when-a-uitableviewcell-is-selected)をご確認ください。 –
提案のためのThx。 2番目の答えによると、鉱山はうまくいくはずです。明らかに、そんなに損失を与えることはありません。 。 。 。 – RyeGuy
これはあなたの完全な 'DayTableViewController'ですか?データを設定したり、作成したビューの 'GetView'メソッドを返すのはどこですか? – apineda