since its not (yet) possible to use the Storyboard for generating classes and glue code. I had the idea to write the F# classes on my own and do the glueing myself.
So I written this loading of the Storyboard namespace
open System
open MonoTouch.UIKit
open MonoTouch.Foundation
[<Register("AppDelegate")>]
type AppDelegate() =
inherit UIApplicationDelegate()
member val window = null with get, set
override this.FinishedLaunching(app, options) =
this.window <- new UIWindow(UIScreen.MainScreen.Bounds)
let Storyboard = UIStoryboard.FromName("MainStoryboard", null)
this.window.RootViewController <- Storyboard.InstantiateInitialViewController() :?> UIViewController
this.window.MakeKeyAndVisible()
true
module Main =
[<EntryPoint>]
let main args =
UIApplication.Main(args, null, "AppDelegate")
0
and the following controller class
open System
open System.Drawing
open MonoTouch.UIKit
open MonoTouch.Foundation
[<Register("HomeController")>]
type HomeController() =
inherit UIViewController()
override this.ViewDidLoad() =
base.ViewDidLoad()
System.Console.WriteLine("FOO!")
Then I created the Storyboard (see attached pictures).
AND - everything gets loaded and the storyboard works fine - One exception: ViewDidLoadnever gets called. Obviously I was not successful in attaching my hand coded controller.
Does anybody have an idea how do accomplish this?
Create a new Storyboard file by right-clicking on the project to Add > New File > iOS > Empty Storyboard. Add your Storyboard name to the Main Interface section of the iOS Application. This does the equivalent of instantiating the Initial View Controller in the FinishedLaunching method within the App Delegate.
For app development, Xamarin uses two methods: Xamarin. Forms and Xamarin Native. Forms, while native UI technology and MVC or MVVM Cross Architecture are used in Xamarin Native. MVVM and XAML are used in Xamarin.
I found the answer. Instead of creating a Controller without parameters
[<Register("HomeController")>]
type HomeController() =
inherit UIViewController()
One must create a controller with an pointer and init the base controller with that pointer too.
[<Register("HomeController")>]
type HomeController(handle:IntPtr) =
inherit UIViewController(handle)
one has to add the following code to your view controller
[<Register("HomeController")>]
type HomeController(handle:IntPtr) =
inherit UIViewController(handle)
let mutable _Clicker = new UIButton()
[<Outlet>]
member this.Clicker
with get() = _Clicker
and set value = _Clicker <- value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With