mickhsmith
mickhsmith

Reputation: 25

Segue not firing from TableViewCell in Swift

I've set up segue from UIButton which works OK, but a segue i've set up on a TableViewCell does not work.

The TableViewCell highlights on touch, but the segue does not fire off. The TableViewCell is highligting in grey, but I set it to Blue.

The segue is a selection push segue.

I've done this in Objective-C many times with no problem, why dosn't it work in Swift.

Hope someone can help me with this.

Upvotes: 1

Views: 847

Answers (1)

mickhsmith
mickhsmith

Reputation: 25

I've solved my problem by changing the following :-

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
  let cell:UITableViewCell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier:"categorycell")
}

changed to :-

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

and the segue now fires.

Thanks to everyone who tried to help.

Upvotes: 1

Related Questions