我这样做:https://developer.xamarin.com/guides/ios/user_interface/controls/tables/creating-tables-in-a-storyboard/
但我无法获得public override void PrepareForSegue(UIStoryboardSegue segue, Foundation.NSObject sender)
当我点击桌子时被叫到。
为什么?
以前有人有这个问题吗? 我下载他们的项目并且它可以工作,但它不在我的项目中。为什么?我错过了一些东西,但我不确定它是什么。
public partial class ViewController : UITableViewController
{
protected ViewController(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
CreateTableItems();
// Add(table);
// Perform any additional setup after loading the view, typically from a nib.
}
public override void PrepareForSegue(UIStoryboardSegue segue, Foundation.NSObject sender)
{
if (segue.Identifier == "TaskSegue")
{ // set in Storyboard
var navctlr = segue.DestinationViewController as wrestingControllor;
if (navctlr != null)
{
var source = table.Source as ScheduleTableViewSource;
var rowPath = table.IndexPathForSelectedRow;
var item = source.GetItem(rowPath.Row);
navctlr.SetTask(this, item); // to be defined on the TaskDetailViewController
}
}
// var page2ViewController = segue.DestinationViewController as Page2ViewController;
// page2ViewController.Name = "dan";
}
void errorMessage(string message)
{
UIAlertView alert = new UIAlertView()
{
Title = "Error",
Message = message,
};
alert.AddButton("OK");
alert.Show();
}
protected void CreateTableItems()
{
bool check = NetworkInterface.GetIsNetworkAvailable();
try
{
if (check)
{
Service1 client = new Service1();
var schools = client.School_lists();
table.Source = new ScheduleTableViewSource(schools, this);
}
else
{
errorMessage("Error no Internet connection");
return;
}
}
catch(Exception e)
{
errorMessage("Error no Internet connection");
return;
}
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}