accessory action segue (UITableViewController)

后端 未结 5 1733
甜味超标
甜味超标 2021-02-01 07:10

I\'m trying to make segue via IB, that switching views when pressed cell accessory in tableView.

Images from my IB:

1.I\'m dragging from cell of tableviewcontrol

相关标签:
5条回答
  • 2021-02-01 07:28

    Drag a navigationController from object library to your storyboard file and try to do this, it should work.Your next View should have the navigation controller.

    0 讨论(0)
  • 2021-02-01 07:34

    I just ran into the same problem. Works fine on iOS 6, crashes on 5.1.

    The way I solved it is by using a standard UITableViewCell and creating the accessory button out of a UIButton, on which I put a segue.

    0 讨论(0)
  • 2021-02-01 07:40

    I had this problem when I had ctrl-dragged a segue from the detail accessory button of the prototype cell to the next view controller. So instead I did the drag from the table view controller itself, and added a bit of code to it.

    Objective-C:

    - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
    {
        [self performSegueWithIdentifier: @"EditUser" sender: [tableView cellForRowAtIndexPath: indexPath]];
    }
    

    Swift 3.0:

    func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
        performSegue(withIdentifier: "EditUser", sender: tableView.cellForRow(at: indexPath))
    }
    

    This works for iOS 5.0 - 10.x

    0 讨论(0)
  • 2021-02-01 07:43

    On iOS 5.x, this error also occurs when you create a popover style segue in a storyboard, and (in my case) anchor it to a UITableViewCell.

    In this case, the error message is a completely misleading red herring.

    I'm assuming that iOS 5.x doesn't support anchored popover segues.

    0 讨论(0)
  • 2021-02-01 07:47

    I'm getting this error when I run my application on iOS 5 on an iPod Touch and not on iOS 6 on an iPhone 5.

    The docs say that accessory action was deprecated in iOS 3.0. The bug seems to be that it's being shown and allowed in iOS 6.

    Can you confirm what version of iOS you're testing against?

    https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewCell_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instp/UITableViewCell/accessoryAction

    0 讨论(0)
提交回复
热议问题