FAQ Database Discussion Community


How do you obtain a view from a nib within a playground?

xcode,cocoa,swift,nib,nsbundle
In a typical Xcode project, you can obtain a view from a nib like this: var objects: NSArray?; NSBundle.mainBundle().loadNibNamed("ExampleView", owner: nil, topLevelObjects: &objects) var view :NSView for obj in objects! { if (obj.isMemberOfClass(NSView)) { view = obj as NSView } } // view is now the NSView object obtained from...

How to resize an custom UIView from NIB inside of a UITableViewCell with Swift?

ios,uitableview,swift,uiview,nib
I want to load a custom view to a static UITableViewCell and resize the view to the horizontal bounds of the UITableViewCell. I achieved the loading, but I stuck with the resizing. Maybe some genius will help me :) For this problem, I created a sample project, which can be...

Start a new UIViewController from a UINavigationController

ios,objective-c,uiviewcontroller,uinavigationcontroller,nib
I have a UINavigationController and I want to start from that navigation a new UIViewController that has its own view controller . when I tried to do that , I faced this exception Could not load NIB in bundle loaded)' with name and directory 'Main.storyboardc'' I am adding the new...

Initializing a xib view as a subview of another NSView

objective-c,osx,cocoa,xib,nib
I'm trying to learn OSX development, and I've created a view in a .xib file, and I'm trying to initialize and then add this view as a subview. I've googled how to do this, and all of the solutions are for iOS and use a call such as MyViewClass* myViewObject...

One xib, multiple classes without inheritance in iOS?

ios,objective-c,xcode,xib,nib
I have two classes and one xib. I can't simply use one parent class which will be linked with this xib because it means multiple classes (and of course it is not acceptable for me to insert an object of one parent class into the object/class of the another one)....

IBOutlet properties nil after custom view loaded from xib

ios,swift,uiview,nib
Something strange going on with IBOutlets. In code I've try to access to this properties, but they are nil. Code: class CustomKeyboard: UIView { @IBOutlet var aButt: UIButton! @IBOutlet var oButt: UIButton! class func keyboard() -> UIView { let nib = UINib(nibName: "CustomKeyboard", bundle: nil) return nib.instantiateWithOwner(self, options: nil).first as...

Programmatically Loaded Nib doesn't fill parent container even when Autolayout constraints are set

ios,swift,autolayout,nib
I have a nib that has an init method: override init() { super.init(); self.view = NSBundle.mainBundle().loadNibNamed("myNib", owner: self, options: nil).first as? UIView; self.addSubview(self.view); } In a UITableView cell, I'm loading the nib like this: override func awakeFromNib() { self.myInnerNib = myNib(); self.nibContainerView?.addSubview(self.myInnerNib!); } The nib is freeform, and its constraints...

How to load a NIB from NIB in iOS

ios,objective-c,uiview,nib
I have CustomViewController created via XIB. I also created CustomView via different XIB file that is subclass os UIView. Then I drug UIView to CustomViewController and set its class to CustomView. Problem is here: then I run this app I did not see content of CustomView that I created in...

How to use custom nib view in ViewController multiple times

ios,swift,nib
I am trying to load a custom UIView from nib CustomView.swift import UIKit @IBDesignable class CustomView: UIView { var view: UIView! override init(frame: CGRect) { super.init(frame: frame) xibSetup() } required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) xibSetup() } func xibSetup() { view = loadViewFromNib() view.frame = bounds view.autoresizingMask = UIViewAutoresizing.FlexibleWidth...

Android weight in Ios ( equal width for 7 buttons)

ios,nib
I am trying to emulate the attribue in android android:layout_weight="1" in iOs I have a View with 7 Buttons and I want that they all have the same width and the same margin between them In android you will put weight 1 for all of them and marginLeft = 5(...