Xcode 6 Storyboard Unwind Segue with Swift Not Connecting to Exit

前端 未结 11 2062
栀梦
栀梦 2020-12-02 09:20

When trying to connect a Navigation Bar Button to the Exit item of a ViewController in Xcode 6 (not really sure if it\'s an Xcode 6 problem but worth mentioning as it is in

11条回答
  •  感情败类
    2020-12-02 09:34

    This is a known issue with Xcode 6:

    Unwind segue actions declared in Swift classes are not recognized by Interface Builder

    In order to get around it you need to:

    1. Change class MyViewController to @objc(MyViewController) class MyViewController
    2. Create an Objective-C header file with a category for MyViewController that redeclares the segue action.

      @interface MyViewController (Workaround)
      - (IBAction)unwindToMyViewController: (UIStoryboardSegue *)segue;
      @end
      
    3. In the storyboard, select the instance of MyViewController, clear its custom class, then set it back to MyViewController.

    After these steps you are able to connect buttons to the exit item again.

    Xcode 6 Release Notes PDF, Page 10

提交回复
热议问题