Xamarin DesignTime Custom Controls Render in XCode, edit control properties in DesignTime - ios

I am developing an application on Xamarin.iOS and MvvmCross platforms. I use xib files instead of storyboards for design interfaces (navigation in my app based on ViewModels). How can I use Xcode's Interface Builder to render my custom controls & edit properties in IB?
Adding attributes [DesignTimeVisible (true)] for class and [Export ("Counter"), Browsable (true)] for properties does not work for XCode Interface Builder.
As far as I know in Objective-C classes there must be set #IBDesignable & #IBInspectable, if you want design time support in Xcode for custom controls.

I believe this is not possible with XCode Interface Builder since it needs to build the custom control in order to present it. And the XCode project generated by Xamarin is not buildable it is used only to track changes and generate C# code.
However you can take a look at the Xamarin Studio’s iOS designer. I think it has the feature you need.

Not exactly what you asked for but Xamarin do support basically the same thing, only using their iOS designer (which I have found rather flaky...)
https://developer.xamarin.com/guides/ios/user_interface/designer/ios_designable_controls_walkthrough/
edit: I just noticed the guy above also gave the same solution, his link is to the designer docs, mine is to the custom properties walkthrough so i'll leave it up :)

Related

Reusable / Shared View not showing in Simulator

I created a Framework so that I can reuse views across several projects. I used this link to create the Framework. I can reference it in a project and the shared views do show in the storyboard. However, when I run it in the simulator, the sharable views are white. Attached are screen shots of what I'm experiencing. I'm using swift 3.0 and xcode 8.2.1.
In the Identity Inspector of the View, change the module of your class to the name of your framework.
References to custom classes need to have both the class name and module set in the Identity Inspector when using Storyboards. At the time when the custom class is set, your that class was in the app’s module, but now it’s in the framework.

Is it possible to export a Balsamiq mockup to Xcode?

I am about to get underway with a project, and wanted to know if it were possible to export a design mockup to Xcode 7.3. I've done some searching on google for the answer and I've seen you can add images, but I wanted to know if you could export whole wireframe projects or if i just have to recreate it all in Xcode using the wireframe as reference?
It doesn't seem to be possible for Balsamiq to export to code. You will have to rebuild the interface in Xcode's Interface Builder, as you will be able to use Autolayout and Size Classes to create truly responsive interface for all Apple products.
References:
[1] Balsamiq support "Export to Code"

IBDesignable controls in a framework

I've watched the excellent video on IBDesignable https://developer.apple.com/videos/play/wwdc2014-411/ and have created a framework with a control in, to be used by my main app (and shared, if necessary).
I've created a custom 'composite' control using IB, as per this great tutorial, http://supereasyapps.com/blog/2014/12/15/create-an-ibdesignable-uiview-subclass-with-code-from-an-xib-file-in-xcode-6
The technique works well and I can now place my designable controls on my storyboard.
The problem is that I notice that all my IBOutlets and IBActions in my 'framework' appear in IB on my storyboard. But I wish to hide them! The functionality for the controls is hidden within the framework and the IBOutlets and IBActions have been created as such to facilitate their operation within that framework, with notification to the outside-world being handled via delegates or some other means.
This technique is compelling in that I can use it to create a reusable library of 'composite' controls but it would be useful to hide certain IBOutlets and IBActions from the library's implementors to ensure an element of 'security'
Can this be done?
Are there any flags to hide IBOutlet/IBAction elements within the framework?
When you speak of security, if you declare of #IBActions, #IBOutlets etc... as Internal, then they're private to your App's module.
In terms of frameworks, they consist of their own module (check in build settings, Module Name) and make sure "defines module" is enabled.
This ensures that your module is for starters "enabled" i.e. everything in your Framework (or app, or bundle which have their own modules defined) have their own environment.
From there, make sure that you've used the correct privacy when it comes to declarations:
Access control is explained is better detail here:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html

ios 5 - Code to Reflect on Storyboard

When you create an interface with Storyboard (OR normal IB) the code is generated at compile time for the app. In other words, it does not update the file of the ViewController it is linked to.
Is there a setting that allows for this?
For me I would see that as a great learning tool.
Like if I put a button on a certain place in a UIView, what would that look like in code?
Cheers Jeff
Unfortunately there is no such setting. XIB's and Storyboards are stored as XML files, and rendered into UI at runtime. On the other hand, when you create UI programmatically you write your code in Objective C using Cocoa Touch classes. There is no direct way to convert the XML into Objective C during development.

Display UIView On a Mac

First off all I don't have much experience in Mac Desktop Programming. I only worked on iOS apps.
Now I would like to make a desktop application that helps me develop iOS apps. To do that I would need to display a UIView (loaded from a xib) on the desktop, similar to how interface builder works.
As far as I know desktop applications use NSView. Is there any way to display a UIView inside a NSView?
EDIT: Is there any way to convert a UIView to a NSView?
EDIT2: Is there any way to write plugins/extensions for Interface Builder?
EDIT3: I'm trying to build an application that would make the development of certain iOS apps(presentation apps) easier. For example an app that displays multiple views in a scrollview, each view having some graphical elements that are animated and some buttons that make a popup appear. This kind of apps are easy to develop but tedious. I would like to make a tool that would help me build such apps faster.
Thanks.
UIKit (the iOS UI framework, including UIView) does not run on OS X (the Mac desktop OS). There have been several efforts to create a 3rd party UIKit port to OS X. Of these, Chameleon may be the most advanced. It still implements only about 60% of UIKit (according to the project page), but has been used in shipping applications. It was developed by the makers of Twitterific to port their iOS app to OS X, and I believe is still the foundation of that product on the desktop.
Converting UIView to NSView
There is no way to "convert" a UIView to an NSView. Since you can't load UIKit on OS X (or AppKit on iOS), there's no way to instantiate a UIView and then walk its view hierarchy to instantiate an equivalent NSView. Of course, since the semantics of UIView are different from NSView, it's unclear whether there could be a deterministic mapping. NSView hierarchies are view-based, whereas UIView hierarchies make much more pervasive use of CoreAnimation layers. NSView has its roots in the NeXT AppKit framework. There are a number areas where AppKit is showing its age. UIKit is a fresh start, "fixing" many of these legacy issues in AppKit (of course, introducing it's own future "legacy" issues).
It may be possible to parse the XIB, instantiating roughly equivalent NSViews where there is a meaningful mapping from UIView to NSView. Custom UIViews will be completely off the table in this scheme, and there won't be any way to (easily) match look and feel without writing custom NSViews for each UIView (ala the Chameleon project).
IB plugins
Interface Builder 3 did suppert a plugin architecture. With Xcode 4, Interface Builder no longer supports third-party plugins. Sorry.
Edit
Unfortunately, I don't believe Chameleon can load views from XIBs, so you may have to contribute to the project if you want to load XIB views instead of instantiating them in code... as Ashley points out, you may be diving into a very deep rabbit hole.
NO. UIView only work on iPhone. Use NSView on mac.
Given your description of the app you're trying to build, I might suggest that you write XIB XML directly, rather than trying to manipulate UIViews on OS X. You might use the emulator to lay out the controls, then generate a serialized representation of the hierarchy (position, etc.) on the device. You could generate XIB XML from that serialization, either on the device or on your desktop after pulling the serialized form back from the emulator.
No, there isn't. One is part of the Cocoa (Mac) framework, the other is in CocoaTouch (iOS).
Not sure what you mean by convert a UIView to a NSView
What are you trying to achieve? Perhaps there are other ways to accomplish your goal.
You might want to check out http://chameleonproject.org/

Resources