Swift user
Swift user

Reputation: 26

How to control several same UIViews in one UIViewController

I’m try? iphone app. There is one ViewController which contains three same UIViews. UIViews are inherit from the one custom uiview class which i made in xib file and connect to ViewController. View contains a switch. How ViewController should recognize which views switch tapped user?

Upvotes: 1

Views: 132

Answers (1)

Glenn Posadas
Glenn Posadas

Reputation: 13283

Welcome to Stackoverflow. Let's answer the key question in your post:

How can the ViewController recognize which views switch tapped user?

There are multiple ways for you or your controller know what view is what, which view did this or that, etc...

  1. Assign Tag to a view. e.g. self.myView1.tag = 1 .
  2. Assign specific class to a view.

From there you'll be able to make your all similar views distinguishable.

Upvotes: 1

Related Questions