a designer h开发者_JAVA百科ere, coding newb. I just created a mockup in photoshop, (a dashboard that shows graphs, with fancy sliders, drag drop, modal box) and want to make a prototype in monotouch, especially with the interface builder, but i got a problem with the screen orientation. i want to force it to landscape mode. I created a ViewController
and place a ImageViewer
inside in with the background and set it to landscape mode, but it still is portrait mode, even if it's forced to landscape mode. Also used the code
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
return ((toInterfaceOrientation == UIInterfaceOrientation.LandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientation.LandscapeRight));
}
How would you start this project if you're looking at the mockup images? For me as a designer i want to add a background as main viewer and all the other boxes as subviewers in the interface builder so that a developer can code, but i'm kinda stuck with the forced landscape and i'm not sure how to proceed with the subviewers connecting with the main view, and if pressed on a subviewer a modal box will appear.
I have added screenshots of the mockup and the files.
Screenshot, downloading link
Ok, there are several things you have done wrong. Read on:
In MonoDevelop:
Remove the RegisterAttribute from the MyViewController class. It will be added automatically in its partial declaration after you compile.
Add the partial modifier in the class declaration:
public partial class MyViewController : UIViewController
Add the following constructor in it:
public MyViewController(IntPtr handle) : base(handle) {}
In Interface Builder:
Disconnect and remove all the outlets you have set. They are wrong because you have set the same outlet for the controller AND the image view.
Add an outlet in the AppDelegate class for the controller (eg. myController). Connect it with your controller.
Add an outlet in MyViewController named "view" and connect it with the image view.
MOST important: in the Identity tab of MyViewController, set its class name to... MyViewController.
After that, it will work correctly.
精彩评论