Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to test the Live rendering in Xcode 6

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

like image 543
SRI Avatar asked Jun 05 '14 12:06

SRI


2 Answers

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.

like image 93
user2221664 Avatar answered Nov 15 '22 09:11

user2221664


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{


}
like image 44
kkocabiyik Avatar answered Nov 15 '22 09:11

kkocabiyik