I can say I suffered a lot with that
The first thing I make must be inside the Main.cs' Finished Launching:
// This method is invoked when the application has loaded its UI and its
ready to run
public override bool FinishedLaunching (UIApplication app, NSDictionary
options)
{
window.AddSubview (navigationControllerMain.View);
window.MakeKeyAndVisible();
return true;
}
My navigationControllerMain is defined on Interface Builder, following
Professional Iphone Programming With Monotouch And Net/C# book. Inside that,
on IB, is has defined my FormLogin ViewController to be my first view to
show on navigationController load. But you can have a FormLoader here, that
loads some view controller at launch.
>From FormLogin, I pass to next ViewController with:
this.NavigationController.PushViewController(new FormHome(), true);
So it says to FormLogin something like: Navigation Controller of formLogin,
please push another view controller, called FormHome. So on FormHome you can
call another ViewControllers, and so on.
And you can call other kind of "windows/forms" that in truth all are
ViewControllers.
So in the above sample I have a Main.cs, a FormLogin.cs view controller and
a FormHome.cs view controller.
(As I'm a all-devices-from-windows-developer I'm calling things like I call
on windows, so on windows my FormLogin, that is really an instance of Form
class is called FormLogin. On iOS my FormLogin is an intance of
UIViewController.
Of course as it's all .NET, it give me the chance to create a Form class
inherited from UIViewController so all my view controlers are now intances
of Form like o windows. But don't try it on home, lol. So I have now
Closing events do do things, localization routines mixing iOS native with
.NET and my own and now my app knows the difference between es-CL and es-MX,
making the UI auto translatable as on windows. Falling in love in the mimmic
cool things where it doesn't exist. Is that the Xamarin C# philosophy?
Kidding.)
The other "kind" of "windows" could be opened like that:
formAnotherViewController = new FormAnotherViewcontroller();
this.PresentModalViewController(formAnotherViewController, true);
Or
formAnotherViewController = new FormAnotherViewcontroller();
this.NavigationController.PushViewController(formAnotherViewController,
true);
Where FormAnotherViewController must be declared global inside the class.
As on windows I never created forms by code, just using resource editor of
Visual Studio, so I'm facing Interface Builder in the same way and also
application structure, and I'm still alive. I think. So I don't know if this
will help you in anything if you're using all from code like a manager of
view controllers.
(But I can say that with that I have now Forms on iOS, with Show(),
ShowModal(), with code that executes on Close, with Owner, with many things
that mimmic window. And also will do the same on Android and the same on
WP7, using a bit of Extensions in some cases and inheritance, maybe could
make any windows developer to adapt to iOS and Android at work, so UI,
database, localization and sync could be the same on everywhere. Thanks
Xamarin for that)
Karl
From: competent_tech <[email protected]>
Date: Fri, 16 Sep 2011 14:16:21 -0700 (PDT)
To: "[email protected]" <[email protected]>
Subject: [MonoTouch] View control questions
I am going absolutely insane trying to figure out how views are loaded into
the application at run time. Here is my scenario:
I have an application logic controller that is (or will be) common to
Monotouch, Monodroid, Windows Phone, and Windows Tablet applications (it is
already running for Windows Phone and Tablet).
This controller performs tasks and is responsible for asking the UI to move
to the appropriate view based on the result of a previous task. For example,
on startup, the logic controller verifies whether or not the application has
previously been configured and, if not, asks the UI to present the
configuration view to the user. Once the user has completed the
configuration dialog, the application logic controller asks the UI to
present the login view.
In many cases, particularly during the initialization portion, the user must
not be able to navigate backward or forward so a navigationcontroller is not
necessarily appropriate at this stage (after the user has logged in, it will
probably be appropriate).
The important thing to note is that this application controller logic is not
embedded in the UI layer, it is contained in a separate project that is
referenced by and initialized from the UI layer. The UI layer contains a
class that implements an interface which is responsible for causing the UI
to move to the appropriate view.
My issue in this design is in trying to figure out how to change the view
based on the requests from the application logic controller. The current
design consists of a mainwindow in which I load up an initialization view
(splash screen), but after that, even if I have a reference to the main
window stored in the interface implementer, I cannot get the view to change
(I am trying to use Window.AddSubview with a cached reference to the Window
object created in the ApplicationDelegate, but the view never changes).
Almost all of the samples and documentation that I have found on the web
either deal with a single view or have a navigationcontroller; none that I
have found have this type of design.
I just need to understand how to cause the window to display any given view,
but I don't comprehend how to make this happen at this point, most likely
because I am missing a very important concept. Can anyone shed any light on
this for me?
--
View this message in context:
http://monotouch.2284126.n4.nabble.com/View-control-questions-tp3819163p3819
163.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch