Failed to check Live rendering in Xcode 6

I recently downloaded the new beta version of Xcode 6 . Apple docs say that we can see the output when editing the code in a .swift file without building and running. I have not found a way to render in real time. Could you help me with this? thanks in advance

+6
source share
3 answers

It is important that you create your project as a cocoa touch framework!

Then:

1.) Add @IBDesignable to your custom UIView before defining the class. (It might be useful to override the drawInRect function to begin with.)

2.) Add a UIView object to your .xib or .storyboard file when it changes its class to its customView with the @IBDesignable attribute.

It should work.

Tipp: Watch this year’s WWDC videos: β€œWhat's New for Interface Builder in Xcode 6” - explains how to set it up.

+2
source

In fact, you do not need to create a Cocoa Touch framework. If you create a user view with nib that contains user interface elements and show them a different view, just add the code to your user 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 do not have the main package when you are in development mode, you will not be able to get your own view for rendering. In addition to this, if you have additional properties and set them on your ui elements, you can do this in the method

 -(void)prepareForInterfaceBuilder{ } 
+1
source

This is my solution. Custom view

  • Custom view
  • Live Render (Objc)
  • Live Render (Swift)

Another solution How to make awesome user interface components in iOS 8 using Swift and Xcode 6 . (Swift, didset, live render)

0
source

Source: https://habr.com/ru/post/970391/


All Articles