Making connections between views and code in ios

Adding views from the storyboard to view controllers or custom view class.
Use the split view to put the storyboard and the class file side by side, then press Control + Click the view in the storyboard + drag it to the view controller class, a dialog will pop up, select outlet and give it a name, then click connect. It will create an outlet in the controller for the view you dragged from the storyboard. The following two examples added an UIImageView and a UILabel to the custom view class ContactViewTableCell.swift

drag imageview and create outlet

draw view and create outlet


Adding code for responding to a button tap in the view controller. Use the split view to put the storyboard and the class file side by side, then press Control + Click the view in the storyboard + drag it to the view controller class, a dialog will pop up, select action and give it a name, then click connect.

create an action for button tap


Assign view controller class or custom view class to the views on the storyboard.Select the view on the storyboard, then select the identity inspector tab in the Utilities panel on the right, then select the controller class or custom view class for the view selected.

controller class

custom view class


Assigning an identifier for a custom view. The identifier tableCell will be used in the tableview controller to find the cell and populate data into it.
assigne identifier

https://github.com/codexpedia/ios_tableview_example
https://github.com/codexpedia/ios_ui_code_connection

Search within Codexpedia

Custom Search

Search the entire web

Custom Search