I need to create a simple login form (Username / Password) for a demo using Xamarin.iOS, but I would prefer not having to dive into XCode for this at this moment.
Maybe something similar to what you can do in other .NET technologies:
var panel = new Panel();
panel.Controls.Add(new Label("Username"));
panel.Controls.Add(new TextBox("Password"));
Is there a way to create simple interfaces in Xamarin for iOS programatically? Or it is required to design the interfaces using XCode only?
Xamarin. iOS allows developers to create native iOS applications using the same UI controls that are available in Objective-C and Xcode, except with the flexibility and elegance of a modern language (C#), the power of the .
To build Xamarin. iOS apps with Visual Studio 2019 or Visual Studio 2022 on Windows, you will need: A Windows machine with Visual Studio 2019 or Visual Studio 2022 installed. This can be a physical or a virtual machine.
You can build native apps for Android, iOS, and Windows by using C# or F# (Visual Basic isn't supported at this time). To get started, install Visual Studio, select the Mobile Development with . NET option in the installer.
Check your operating system version and follow the instructions for the Xamarin installer. Xcode 10 requires macOS High Sierra (10.13) or newer. The iOS 12 SDK ships with Xcode 10. You can still target older Android versions while using the latest SDK, or you can build against older versions of the SDK if required.
Yes, you can create UI via code. Using XCode's designer is entirely optional.
UIButton btn = new UIButton (UIButtonType.RoundedRect);
btn.SetTitle ("Hello", UIControlState.Normal);
btn.Frame = new RectangleF (50, 50, 50, 50);
btn.TouchDown += delegate {
UIAlertView alert = new UIAlertView("Hello", "Hello, Xamarin!", null, "OK");
alert.Show();
};
this.View.AddSubview (btn);
For data entry UI, you may also want to consider using MonoTouch.Dialog.
Perhaps a little late to the game, but have you tried just using a UIAlertView and then doing:
yourAlertView.AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput;
It'll create a popup login window with the textfields already setup for you.
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