Reputation: 11
I am following the tutorial here:
http://software.tavlikos.com/2011/10/13/uipageviewcontroller/
Basically, on one machine running the latest monodevelop and the latest monotouch, the code works fine and the app works perfectly. On another machine, using the same version of monodevelop and monotouch the app crashes out because the pageController.view is null. So it dies and throws an error when trying to assign the frame size. Any idea why this is happening?
Below is the code for that section. (in the 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);
Upvotes: 1
Views: 134
Reputation: 32694
The difference in behavior could be caused by a change in order in how the events are raised by iOS. We found a change in iOS 5.1 [1] where they now raise events during certain methods that previously were not raised until later.
To solve this problem, make sure that you assign your DataSources or other event handlers before you set properties that might raise events, see this blog post for some more details:
http://spouliot.wordpress.com/2012/03/26/events-vs-objective-c-delegates/
[1] https://bugzilla.xamarin.com/show_bug.cgi?id=3803
Upvotes: 2