Monotouch ..两台机器上的不同反应

时间:2012-03-29 15:50:16

标签: ios5 xamarin.ios

我在这里遵循教程:

http://software.tavlikos.com/2011/10/13/uipageviewcontroller/

基本上,在运行最新monodevelop和最新monotouch的一台机器上,代码工作正常,应用程序运行完美。在另一台机器上,使用相同版本的monodevelop和monotouch应用程序崩溃,因为pageController.view为null。因此,它会在尝试分配帧大小时死亡并抛出错误。知道为什么会这样吗?

以下是该部分的代码。 (在ViewDidLoad中)

// Initialize the first page
BookPageController firstPageController = new BookPageController(0);
this.pageController.SetViewControllers(new UIViewController[] { firstPageController }, UIPageViewControllerNavigationDirection.Forward, false, s => { });
this.pageController.DataSource = new PageDataSource(this);
this.pageController.View.Frame = this.View.Bounds;
this.View.AddSubview(this.pageController.View);

1 个答案:

答案 0 :(得分:2)

行为的差异可能是由于iOS引发事件的顺序发生了变化。我们在iOS 5.1 [1]中发现了一个变化,他们现在在某些方法中引发了事件,这些方法以前没有被提出过。

要解决此问题,请确保在设置可能引发事件的属性之前分配DataSource或其他事件处理程序,有关详细信息,请参阅此博客文章:

http://spouliot.wordpress.com/2012/03/26/events-vs-objective-c-delegates/

[1] https://bugzilla.xamarin.com/show_bug.cgi?id=3803