我遇到UINavigationController
的问题。这是我正在使用的代码:
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace SalesOrderTest
{
public partial class RootViewConroller : UIViewController
{
public RootViewConroller () : base ("RootViewConroller", null)
{
this.Title = NSBundle.MainBundle.LocalizedString ("Main", "Main");
this.TabBarItem.Image = UIImage.FromBundle ("Images/first");
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.chooseCustomerSearchButton.TouchUpInside += (sender, e) => {
var single = new SecondViewController ();
this.NavigationController.PushViewController (single, true);
};
// Perform any additional setup after loading the view, typically from a nib.
}
public override void ViewDidUnload ()
{
base.ViewDidUnload ();
// Clear any references to subviews of the main view in order to
// allow the Garbage Collector to collect them sooner.
//
// e.g. myOutlet.Dispose (); myOutlet = null;
ReleaseDesignerOutlets ();
}
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
// Return true for supported orientations
return true;
}
}
}
单击按钮后,收到以下错误消息:
未处理的异常:System.NullReferenceException:对象引用 未设置为对象的实例 SalesOrderTest.RootViewConroller + C_ AnonStorey0<> M _0 (System.Object sender,System.EventArgs e)[0x00000] in /Users/Mac/Projects/SalesOrderPolarisnet/SalesOrderTest/RootViewConroller.cs:34 在MonoTouch.UIKit.UIControlEventProxy.Activated()[0x00000]中 /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30