Swift put multiple IBOutlets in an Array

前端 未结 4 1945
走了就别回头了
走了就别回头了 2020-12-05 17:25

\"Multiple

I made these (marked with red border) IBOutlets using ctrl + drag

But i

4条回答
  •  我在风中等你
    2020-12-05 18:00

    Start with the two view pane where you see both your code and the storyboard. When you make your first IBOutlet connection from the UI to your code, just look carefully at the Connection drop down field and select the option called "Outlet Collection". This will automatically create an array of IBOutlets. Next just look for the little black circle within a circle that is placed in your code where the array is created. Just drag from this circle to all the other UI objects you want to connect to that same collection (not sure if you can mix types). Similarly you can connect all the objects to one Action by dragging from the first black dot created to all the other objects you want to wire up to that action. Also consider EnumerateSequence() to help in working with this Collection. Sweet right?

提交回复
热议问题