Can I hardcode my StoryBoard? - xcode

I'm new to iOS developing and xCode from WPF C# (where I almost never drag and drop but hard code my "view"). In xCode 4.2, does all the view in MVC contains in the MainStoryBoard.storyboard? Can I hardcode my view (or, can I hardcode my storyboard or view its source code)?

You can create an entire app without touching interface builder or storyboards. But I'd strongly recommend actually using them instead - if you're writing an iOS app, write an iOS app, don't try and crowbar in practices from a different framework.

Related

How do you mix Xamarin.Forms with Xamarin.Native using MvvmCross?

According to MvvmCross 5.3 documentation you can mix Xamarin.Forms and Xamarin.Native:
"With MvvmCross 5.3, you will now be able to mix and match Native Xamarin views with Xamarin.Forms pages using ViewModel navigation!"
My scenario is the solution contains Xamarin.Android and Xamarin.iOS projects which rely quite heavily on MvvmCross. Going forward I would like to be able to create new views/pages using Xamarin.Forms. I'm assuming this is what is meant by "mix and match".
Other than the above statement I can't find any documentation or examples on how to do this.
I tried extending the MvvmCross TipCal app to show a new Xamarin.Forms view/page without any luck.
Can someone explain or provide an example of how to mix and match Xamarin.Forms with Native Xamarin using MvvmCross?
I think if you truly want to mix forms/native you need to either create a custom view presenter or trick the existing view presenter to "embed" a forms page into a viewcontroller/fragment/activity.
I have created a helper library as a proof of concept to embed Xamarin.Forms content pages into fragments/activities/viewControllers but could use some help ironing out some bugs with Android. It seems to work fine for iOS.
Let's take iOS as an example.
This approach has you create you content page as normal, but also create a wrapper viewController. You embed the content page in the viewController and when you navigate, you navigate to the viewController wrapper instead of the content page.
https://github.com/dornerworks/Mvx.Forms.PageWrapper.iOS
https://github.com/dornerworks/Mvx.Forms.PageWrapper.Android

Is there a way to mix native code screens and Xamarin screens

I have a very important library written in swift with 3D rendering model on scenekit. So is there a way to mix native code screens and Xamarin screens without the need to go through the binding path? Meaning, I want to keep my app on xamarin as is, but I want to add some screens in pure native swift code.
So is there a way to mix native code screens and Xamarin screens
without the need to go through the binding path?
Short answer is no, you cannot.
When you have swift code and need to use it with xamarin apps you have only two ways.
Binding way as you mentioned
Rewrite you library from swift to c#.

Xamarin - mixing Forms and Storyboards

Is it possible to mix iOS Storyboards and Xamarin Forms within one application? I have a bunch of views that are easier to be created in Forms, but some which are heavily customized so we would need to create some of them in native code.
I would like to use Storyboards to create the native parts, but can't seem to find a way to navigate from a Forms page to a Storyboard and vice versa.
I don't mind doing it from code, just need to know the direction to look into and if it's even possible.
You can create native views using the concept of Custom Renderers (see links below). The idea is that you create a Xamarin Forms Control that's shared between all platforms and which old common properties (like colors, general data etc), and do the native rendering on the iOS/Android/WP projects.
So, for your storyboard, you can create it usign Xamarin.iOS, and render using a Custom Renderer. The link posted by #GSerg in the comments have some information and examples, but you can take a closer look at the oficial documentation as well:
Introduction to Custom Renderers
Customizing Controls on Each Platform
Customizing Control Rendering in Xamarin.Forms (video)
Also, for more real world examples you can take a look at the Xamarin Forms XLabs project.
Thanks to Rafael Steil's answer. I looked at the links and a few more samples.
Notably:
Custom Renderer Map
Using Xamarin Forms alongside Storyboard
And I created a sample project to show the back-and-forth navigation between Xamarin Forms and pages created in Storyboards. You can find it over here:
Xamarin Forms Mixed with Native

Handling UI in Xamarin.IOS

I am a new iphone developer using xamarin studios.I wanted to know if i need to learn objective-c for handling the ui in xcode?
For example,i have made a UIView(subview) in my viewcontroller(.xib) and i need to generate many such similar UIViews on same button click.
So do I need to write the event code in xcode .h or .m file or in the .cs file in xamarin studios?
No, you do not need to learn Obj-C. It's helpful to be able to READ it, because Apple's samples and docs (as well as a lot of reference material on the web) are written in Obj-C. But you can create your UI using XCode's design tools or directly in code with C# without having to write any Obj-C code.
The views can be created in xib using interface builder or by code using c#, for the event you have to do it in cs file like in csharp.
No, the Objective-C .h/m. files that Xamarin Studio generates in the Xcode project are just stubs mirroring the actions and outlets on your exported C# classes, so that Xcode UI designer (which only understands Obj-C) can connect to them. You can add outlets/actions to these stubs using Xcode's control-drag connections system, and those will be synced back to C#, but anything more advanced added to the obj-c stubs will be ignored. You must write your actual implementations in C#.
You don't need to learn Objective-C, although it will be helpful. It's more important to be familiar with the Cocoa Touch frameworks, particularly UIKit; this knowledge is no less useful when developing with Xamarin.

Not seeing my view in simulator using XCode 4.2

I have downloaded Xcode 4.2 and I'm having problems viewing my project in the simulator. I'm getting a blank whit view when I run the simulator. I'm using a single view application. I created a interface .h, .m, .xib... I have connected all actions and outlets and saved everything. My thoughts are that I have overlooked something simple. again, I just started using Xcode 4.2 today. Help!
I am assuming you are not doing this
if((self = [super initWithNibName:#"MyClass" bundle:nil])) {
// do stuff here
}
This isn't enough information to tell what's wrong with your code.
That said, if create new project in XCode using the "Single View Application" template you can see how everything is hooked up and you may be solve your problem with a 'how is mine different?' comparison.
If that fails... post some code and we might be able to see the issue.
Edit: From your screenshot it looks like you are mixing storyboards and XIBs. If you are using storyboards, then you won't see .xib files. They are inside your storyboard. You can click on the storyboard file and edit the first XIB which loads when your app runs as well as create new ones. You can still do things the "old" way by just unchecking storyboards when you first create the app. On a side note, it is possible to mix storyboards and straight XIBs, but I don't think that's what you were going for.
At a guess, you created a project with storyboards, then added a XIB manually and you get a blank XIB. Try clicking on the storyboard and modifying the XIB in there. I bet they will show up when you run your app.

Resources