Xcode 6: can't connect any IBOutlet to ViewController

后端 未结 16 1812
眼角桃花
眼角桃花 2020-12-03 07:17

After upgrading to Xcode 6, I opened an old project (that contains a subproject, so it has many targets) and I noticed that no link from my Storyboard ViewContoller to the r

相关标签:
16条回答
  • 2020-12-03 07:54

    Here's the proper solution i believe.

    If you renamed the controller in code, you need to update the .xib file.

    I could not find a way to do it in the interface builder, so do this:

    1. Open the .xib file with a text editor: right click the file > open as > source code

    2. In the <objects> node find the <placeholder> node with the property placeholderIdentifier="IBFilesOwner" and replace the value in customClass="MyOldControllerName" with your new controller name: customClass="MyNewControllerName"

    And all your IBOutlets will work as normal again.

    0 讨论(0)
  • 2020-12-03 07:54

    no one solution fixed my same problem... But i have solved by:

    • close xcode
    • renaming the folder of the project
    • open xcode

    and then the outlets will be back again

    I hope that this solution is the right one for the people who have the same problem

    0 讨论(0)
  • 2020-12-03 07:56

    I've experienced similar behaviour in Xcode 6.1.1 when trying to add the first outlet to a new view.

    Tried removing the references and adding the files again as suggested above with no success.

    What I did find worked was writing the first property on the new view by hand. I just popped in:

    @property NSString *temp;
    

    I could then attach my outlets in the normal way. Just delete the temporary property once you've added your first outlet.

    Hope this helps.

    0 讨论(0)
  • 2020-12-03 08:00

    I had this, affected all projects on my machine, swift and objective c and drove me mad for ages. Finally also noticed that I could not use the refractor to rename classes either.

    The fix for me was:

    1. Close xcode
    2. Delete ~/Library/Developer/Xcode/DerivedData (just doing this on its own did not work!!)
    3. Delete all user data for all my projects using the following from the directory that contains all my projects e.g. /src (be careful with this command!):

    find . -name 'xcuserdata' -exec rm -rf {} \;

    If you want to do it by hand just do the following for all your projects Delete .xcodeproj/project.xcworkspace/xcuserdata Delete .xcodeproj/xcuserdata/.xcuserdatad

    1. Get Spotlight to re-index the drive all my projects were on (not sure if this was required
    2. Re-boot machine

    Everything sprang back into life !

    0 讨论(0)
  • 2020-12-03 08:03

    I was having this same issue.

    It turns out I renamed my view controller class and file name. In storyboard, I had the stale value in the right pane, Custom Class -> Class. So the IBOutlets were not aligning because there were none in the missing class, which is where it was expecting to find the defined outlets.

    Filling in the correct class name of the View Controller in the Custom Class field in the right pane fixed my issue.

    XCode needs to be more verbose if you have a bad class name in the Custom Class fields.

    0 讨论(0)
  • 2020-12-03 08:04

    In your storyboard hierarchy select the View Controller,

    enter image description here

    In the right pane Custom Class section Class, select the drop down and your desired view controller.

    enter image description here

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