Handling UI in Xamarin.IOS - xcode

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.

Related

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

Can I hardcode my StoryBoard?

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.

Connecting interface builder to the code in Xcode 4

I created a new project in Xcode 4 using the "Cocoa Application" template and added a few UI elements as seen below:
Now that I've designed this basic interface I'm at a loss for how to actually respond to user events for that button. What type of class should I create and how do I connect that class to IB?
I realize I could read the 100s of pages of Apple documentation that explains all this, but those tend to be too verbose and slightly overwhelming. Thanks for your guidance!
You Ctrl+Drag connections from your controls to actions (defined in code) of the other objects in your XIB file. Cocoa is a powerful framework and Xcode is a wonderful tool, but you're going to have to do some reading to get started. Here's a good site for beginners: Cocoa Dev Central. I recommend you study the tutorials in this order:
Learn Objective-C
Learn Cocoa
Learn Cocoa II
Objective-C Style I
Objective-C Style II
Then you can do some of the more advanced ones. The tutorials are designed for Xcode 3, but they should not be hard to follow, and it you run into problems, Google is your friend.
Control drag from each UI element to the assistant editor.
If you select outlet then it will generate the property and the ivar along with the proper memory management in the .m.
If you select action then it will create a method that will be called when your UI element is interacted with.
I would post a decent picture but I do not have enough reputation...

Safari Web Inspector-esque functionality in Xcode?

Just starting out in Objective-C, so I'm curious as to how some apps that I enjoy function interface-wise. I've cloned a few apps from Github into Xcode, and I'm looking for something similar to Safari's Web Inspector where I can highlight portions of the application and see what piece of code they refer to?
I think it may have something to do with Interface Builder, but I'm not sure where to begin... help?
Thanks!
This doesn't exist AFAIK. Interface Builder doesn't show a representation of your code, it allows to you to lay out (serialized) interface elements to your app graphically.

Resources