Unable to test the Live rendering in Xcode 6 - interface-builder

Recently I have downloaded the new XCode 6 beta version.In the apple docs it is saying that we can see the output while editing the Code in .swift file without build and run. I haven't find any ways to fulfill the live rendering. Could you please help me out on this? Thanks in advance

It's important that you set up your project as a cocoa touch framework!
Then:
1.) Add #IBDesignable to your custom UIView before the class definition. (It might be helpful to override the drawInRect function for the beginning.)
2.) Add a UIView object to your .xib or .storyboard file at it change its class to your customView with the #IBDesignable attribute.
It should work.
Tipp: Check out this years WWDC video: "What's New to Interface Builder in Xcode 6" - There is explained how to set it up.

You actually do not have to create Cocoa Touch framework. If you create a custom view with nib that contains UI elements and show them another view just add the code below to your custom view
-(instancetype)initWithFrame:(CGRect)frame{
#if !TARGET_INTERFACE_BUILDER
self= [super initWithFrame:frame];
if(self){
}
return self;
#else
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
return [bundle loadNibNamed:NSStringFromClass([self class]) owner:self options:nil][0];
#endif
}
Since you don't have your main bundle while you are on design mode, you won't be able to retrieve your custom view to render. In addition to this, if you have extra properties and set them onto your ui elements, you may do this within method
-(void)prepareForInterfaceBuilder{
}

This is my solution Custom View
Custom View
Live Render (Objc)
Live Render (Swift)
Another solution How to make awesome UI components in iOS 8 using Swift and XCode 6.
(Swift, didset,live render)

Related

unable to create outlet in xamarin for imageview.App crashes

i have used an imageview in the ios builder in visual studio whose refrence is automatically connected to my viewcontroller class and when i do set image to that imageview my app crashes with an error "This class is not key-value complient for the key image__"
As i am new to xamarin i am not aware if we need to do anything else inorder to make relation from storyboard to the class variable for access that particular outlet object.Please suggest me if you have any advice?
Open the storyboard in visual studio and then open properties pad. Select the image view and give Name in the identity option. Outlets from Xcode did not work in xamarin.
For example, your view controller name is TestView and you give the Name to image view as MyImage. Now there is one more file named TestView.designer.cs open that file and you will see that Outlets are generated in that file.
You might have accidentally removed the connection.
Is your imageView name: image__?
Given if the imageView is in ViewController.cs, look at the Solution Explorer, expand and find the ViewController.designer.cs and remove the imageView or image__(in your case) Outlet and whatever that's related to it and then re-link the Outlet again.
The problem was that the refrence was not working properly. I just removed the image outlet and viewController class and closed the project.Then i started creating that same class from very scratch and created the outlet from the storyboard. That was it. Everything started working COOL..!!!
I hope restarting the project helped me and it can help you too.Good Luck.

Can't hook up IBOutlet or IBAction to a View Controller written in Swift after deleting the ObjC version

I created a project in XCode 5 and imported it to XCode 6 beta, then later decided that I wanted to rewrite one of the ViewControllers in Swift. So I first deleted the controller file (both .h & .m) and added the same class named controller within a Swift file extension. Now when I try to hook up an outlet and action from the Storyboard by ctrl-dragging from the widget to the file, I can't create new connections.
Is this a bug or do I need to do something else to get it to work?
Seems to be bug in Xcode 6. You can resolve this by Changing the ViewController Custom class in the identity inspector to some another class press return and again change the class to original class you want then press return.

Is Default Xcode 4.6.3 New Project With Cocoa Application Template Structure Recommended?

I am using Xcode 4.6.3, and I have created a new project using the “Cocoa Application” template. The default structure seems a bit funny to me, and I was wondering if it is the recommended structure.
Specifically, three of the files created by the template are:
MainMenu.xib
AppDelegate.h
AppDelegate.m
The MainMenu.xib file contains the main menu definition, and the definition of the main window. It seems strange to me to have the main window defined in a file called MainMenu.xib. Is this the recommended place to define the main window?
I was expecting to see a files like MainWindow.h, and MainWindow.m subclassed from NSViewController. The current structure created from the template would lead me to create handlers for the main window events in the app delegate. This also seems strange to me. Is it recommend to put the main window outlets and handlers in the app delegate?
One of the first things I do is rip that window out.
I was expecting to see a files like MainWindow.h, and MainWindow.m subclassed from NSViewController.
View controllers are not windows, and windows are not view controllers.
What I do (after deleting the window from the MainMenu nib) is create a window controller subclass, using the Objective-C Class file template and enabling the “and a nib, too, please” option (which appears when the superclass is NSViewController or NSWindowController).
(Don't forget to select the nib afterward and click the button in the File Inspector to make it localizable, since Xcode doesn't do that by default for some reason.)
In the implementation of the subclass, I have something like the following:
#implementation MyWindowController
- (instancetype) init {
return [self initWithWindowNibName:NSStringFromClass([self class])];
}
//and all my app-specific stuff
#end
In the app delegate, I delete the outlet that once referred to the MainMenu-born window, and then I create the window controller:
#implementation MyAppDelegate
{
MyWindowController *_wc;
}
- (void) applicationWillFinishLaunching:(NSNotification *)notification {
_wc = [MyWindowController new];
[_wc showWindow:nil];
}
- (void) applicationWillTerminate:(NSNotification *)notification {
[_wc close];
_wc = nil;
}
#end
(I use ARC; if you don't, you'll want to add a release message in there.)
Is it recommend to put the main window outlets and handlers in the app delegate?
No. That is outside the scope of what the application's delegate should do.
For an extremely simple one-window app, you might want to make the window controller the application's delegate. But even that is different from making an app delegate that isn't a window controller handle actions, be a data source, etc. It's the difference between adding a little bit of responsibility to a window controller, and adding a whole lot of responsibility to an app delegate.
I keep them separate at all times. It's a bit of extra work in the simple cases, but my project is cleaner, which makes me happier, and I usually need to do it sooner or later anyway.

MonoTouch Designer Class Not Available In XCode

I am trying to build a custom TableViewCell, and so far I have created a xib file and laid it out in XCode designer. However, I cannot find my class in the drop down in identity inspector, and I cannot locate the generated class when in content assister.
Is there something beyond creating the xib in MonoDev to make my designer class available to XCode designer?
The (C#) class needs to have a Register attribute:
[Register ("MyClass")]
public class MyClass : UITableViewCell
{
}
Per Xamarin support:
When creating a custom UITableViewCell (and wanting to use the
designer), you have to use a bit of a "hacky" process to get the
code-behind file to work. You are going to want to add the class as a
iPhone (or iPad or Universal) UIViewController, change the superclass
of the class you just created to UITableViewCell. Make your changes in
the Xcode designer (delete view and add UITableViewCell), and then
make your changes in your code-behind file.
There is a great tutorial on how to do this here:
http://www.arcticmill.com/2012/05/uitableview-with-custom-uitableviewcell.html

How to debug the main SafariPlugIn project?

Ok, Now I want to add a menu in the safari menubar. I Create a Cocoa bundle project in Xcode .and then change the target extension is "webplugin" .and then add WebPluginMIMETypesFilename
com.example.webplugin.plist
to the info.plist.but I don't know the is right?. I make the prinpical class is my main plugin class SafariPlug . and then In the safariPlug.m I implement the methods:
// This method returns an NSView object that conforms to the WebPlugIn informal protocol.
(NSView *)plugInViewWithArguments:(NSDictionary *)arguments
{
return [[[self alloc] initWithArguments:arguments] autorelease];
}
(id)initWithArguments:(NSDictionary *)arguments
{
self = [super init];
if (self)
[MenuController sharedController]; // trigger the menu items to be added
return self;
}
at the end I followed the url:run safari to debug plunIn project
add a debug bundle:myProject.webplugin into the folder:/library/internet plug-ins/
But when I make a breakpoint into the
(NSView *)plugInViewWithArguments:(NSDictionary *)arguments
the program didn't load in the debug mode? SomeOne which have experience can tell me the step of add a menu into the safari? Thank you very much!
Safari will not load your plugin unless you load a webpage that references your plugin. So I'm afraid the plugin type you're working on is not officially supported, by the current plugin API of safari.
You can use SIBML to write this kind of plugin. But SIMBL is not something officially supported by Apple, and a lot of people consider it a hack.

Resources