[MonoTouch] Help displaying UISplitViewController from UIViewController
Jeff Stedfast
jeff at xamarin.com
Thu Mar 29 16:36:59 UTC 2012
Hi Chris,
One possibility would be to wrap your ScreenStart view controller in a
UINavigationController. Then, in your Click() event handler, you could
"push" your DataSplitView.
e.g.:
ScreenStart _srcStart; // declared at AppDelegate class level
AppDelegate.FinishedLaunching(....)
{
window = new UIWindow(UIScreen.MainScreen.Bounds);
_srcStart = new ScreenStart();
UINavigationController nav = new UINavigationController (_srcStart);
window.RootViewController = nav;
window.MakeKeyAndVisible();
}
Then...
DataSplitView dsView; // Declared at StartScreen class level
ScreenStart.btnShowData_Click(....)
{
if (dsView == null)
dsView = new DataSplitView();
NavigationController.PushViewController (dsView, true);
}
You'll notice that I moved your view controller declarations into the class
level. This is because you need to make sure that you have a managed
reference to your view controllers so that if/when the runtime tries to
re-surface your view controllers from native code, it can easily map to the
correct object (which it cannot do if you don't have a managed object).
Hope that helps,
Jeff
On Thu, Mar 29, 2012 at 12:16 PM, chris.s <chris.stephens at innov8.co.uk>wrote:
> Firstly, I'm very new to monotouch and still trying to get to grips with
> the
> concept of view controllers.
>
> I've got an app that has a custom UISplitViewController which works fine
> and
> displays as expected when assigned to UIWindow.RootViewController in my
> AppDelegate.
>
> But what I am trying to do is display a 'single screen' view at startup
> (for
> app logon) and then move to the split view when clicking a button on this
> first screen.
>
> I'll give some skeleton outlines of the relevant bits of code i'm using....
>
> AppDelegate.FinishedLaunching(....)
> {
> window = new UIWindow(UIScreen.MainScreen.Bounds);
> ScreenStart _srcStart = new ScreenStart();
> window.RootViewController = ScreenStart;
> window.MakeKeyAndVisible();
> }
>
> ....then my split view class....
>
> public class DataSplitView : UISplitViewController
> {
> protected ScreenDataHeader scrDH;
> protected ScreenDataDetail scrDD;
>
> public DataSplitView() : base()
> {
> scrDH = new ScreenDataHeader();
> scrDD = new ScreenDataDetail();
>
> this.WillHideViewController += .....
> this.WillShowViewController += ......
> }
> }
>
>
> ... then my button click event...
>
> ScreenStart.btnShowData_Click(....)
> {
> DataSplitView dsView = new DataSplitView();
>
> // How do display dsView from here?
>
> }
>
> Any pointers greatly appreciated!
>
> Chris
>
>
> --
> View this message in context:
> http://monotouch.2284126.n4.nabble.com/Help-displaying-UISplitViewController-from-UIViewController-tp4515952p4515952.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monotouch/attachments/20120329/7c245ccf/attachment-0001.html>
More information about the MonoTouch
mailing list