Xcode 7.3 cannot create xib with UIView / UITableViewCell together

After I upgraded Xcode to 7.3, I found that Xcode cannot create a Xib file when I create a UIView or UITableViewCell class. Does anyone know the reason?

+9
ios xcode uitableview xib nib
source share
3 answers

A very traditional way and existing with any version of Xcode.

  • Right click on the left pane
  • Select a new file
  • Choose iOS
  • Choose user interface
  • Select Empty, then next
  • Give the file name.

This will create an empty xib, now drag and drop the UITableViewCell and give the class name as you specified in the .h and .m file or in the quick file name.

enter image description here

Swift class with UITableViewCell

import UIKit class CustomCell: UITableViewCell { @IBOutlet weak var lblName : UILabel! override func awakeFromNib() { super.awakeFromNib() // Initialization code } } 
+9
source share

Yes, this is an amazing problem.

  • First create a file with the file (for example, ProfileHeaderView.xib) from the file → New file.

  • Then create a .swift file (e.g. ProfileHeaderView.swift) and subclass it from UIView.

  • Last (but not least) go to the Identity Inspector of your .xib file and change the class name to the name of the created .swift file (for example, ProfileHeaderView.swift).

Hope this helps.

+3
source share

Make sure you select Cocoa Touch Class in the iOS section and not the OSX Cocoa Class . This allows you to check the parameter. Also create an XIB file. This works fine in Xcode 7.3 for ViewControllers, and any subclasses of UIView (e.g. UITableViewCell, UICollectionViewCell)

EDIT: but not for UIView

+1
source share

All Articles