user1104092
user1104092

Reputation:

How see code-view for view controller in Xcode?

In my Xcode project, I have several view controllers in my storyboard. How can I see the code for a specific view controller?

Because each view controller will need to have different functions from the others. So, where can I write that code?

Thanks!

Upvotes: 4

Views: 22913

Answers (6)

Judah the Hudson
Judah the Hudson

Reputation: 1

We start with multiple scenes in our storyboard.

see picture

  1. Create new view controller file Create new swift file For our custom view controller

see picture

  1. Setup file In our new file, Type in code To set up class structure

see picture

  1. link file to view controller in Storyboard In Storyboard, Click on our view controller

pic a

pic b

pic c

In the Identity Inspector, In the Class field, Type in the name of the new view controller file we created in step 1

  1. open Assistant view

see pic

  1. Done! We are ready to write code In our view controller That is connected to our view controller in the Storyboard

see pic

Upvotes: -1

Bob
Bob

Reputation: 21

Select the storyboard in the navigator, right click and select 'Open As'. You should see 2 options 'Interface Builder - Storyboard' or 'Source Code' - select the Source Code option should fix your issue.

Upvotes: 2

pradope
pradope

Reputation: 31

The "Show the Assistant editor" venn diagram icon on the top right did it for me. Xcode Version 6.4

Upvotes: 3

max lau
max lau

Reputation: 31

  1. Select the View Controller you want to see the code
  2. Go to the Assistant editor

It's on the upper bar to the right.

Upvotes: 3

sch
sch

Reputation: 27536

By default, storyboard will use UIViewController for the view controllers you use.

However you can change the class used for the view controller by:

  1. selecting the view controller (in Interface Builder)
  2. show the identity inspector (View > Utilities > Show identity inspector)
  3. Change the value in Class to "MyOwnViewController"

Where "MyOwnViewController" is the name of the UIViewController subclass that you want to use for that view controller.

Upvotes: 6

zaph
zaph

Reputation: 112873

You subclass each UIViewController to add unique functionality. The implementation of UIViewController is private to Apple, the interface is described in it's documentation.

Upvotes: 0

Related Questions