Nib file designing in Xcode 9 using IB

45 Views Asked by At

I am making ios app, and I am beginer in iOS. I am making an app and in this I am trying to make the custom tableview cell.

For this I Have added a cocoa touch class and also check to create its nib file.

Now in IB I am putting views like UiLabel,Buttons etc int it , making its height bigger in IB. But this is not updating the View. I can not see any thing inside the View.

I want to see it visually so that I can set autolayout constraints through IB. Did any one notice this thing? Why the view of IB is not updating? I have started my mac. but it did not help. Any suggestion please?

Note: I am using Xcode 9.2

1

There are 1 best solutions below

0
Sahil On

Have you registered your nib file as UITableViewCell? First you need to register your nib file in viewDidLoad of your class where you have dropped the outlet of your tableView.

override func viewDidLoad() {
        super.viewDidLoad()
        tableView.registerNib(UINib(nibName: "CustomOneCell", bundle: nil), forCellReuseIdentifier: "CustomCellOne")
    }

After this, go to your tableView delegates,

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("CustomCellOne", forIndexPath: indexPath) as! CustomOneCell
        return cell
    }

Make sure to assign the tableview delegate and datasource.