Subscribe ( )

iPhone Programming Tutorials


 

Forum

You must be logged in to post Login Register

Search 

Connecting a button to switch views

User Post

6:19 pm
September 25, 2008


envex

Noob

posts 5

1

Hello,

I have created 2 views.

view 1 contains a button that, when clicked, i would like to switch to view 2.

I'm trying to frankenstein code from multiple tutorials to learn this on my own, but i need a little help.

When i create the button in view 1, how do i set it's variable name so i can reference it in xcode?

Thanks,

envex

9:28 am
September 26, 2008


Admin

brandontreb

posts 88

2

envex,

I will assume that you have a viewcontroller for each of your views…

Here are some steps to achieve this functionality (its going to be mostly psuedocode).

1.View1's viewcontroller.h

#import view2viewcontroller.h

declare a variable for the view2viewcontroller

View2ViewController *view2;

Create an IBAction for the UIButton that will transition the views when clicked

2. Connect the UIButton to that IBAction using interface builder (examples of how this is done can be found in most of my tutorials)

3. Implement the IBAction method inside of the viewcontroller's .m file for view1

Inside of this method, you need to instanciate view2viewcontroller if it is nil (example in the transitioning between views tutorial)

Now, simply push view2Viewcontroller on to the view stack (again, example in the transitioning between views tutorial)


I hope that helps…

If debugging is the process of removing bugs, then programming must be the process of putting them in.
-Edsger Dijkstra

12:52 pm
September 26, 2008


envex

Noob

posts 5

3

Hey,

Immediatly after posting i found an apple tutorial that should help, and with this new info i think i'm set.

this NDA is becoming a real thorn in my side. It's hard to learn when the leave out so much!

Thanks again!

Search 

About the iCodeBlog forum

Most Users Ever Online:

44


Currently Online:

8 Guests

Forum Stats:

Groups: 2

Forums: 6

Topics: 419

Posts: 893

Membership:

There are 934 Members

There has been 1 Guest

There are 2 Admins

There is 1 Moderator

Top Posters:

bobcubsfan – 54

crazyiez – 30

Uhu – 17

AdeC – 17

Nick – 15

jitesh61 – 12

Administrators: Brandon (88 Posts), Collin (0 Posts)

Moderators: VertigoSol (26 Posts)



©   

  • Posted by on 6 Aug 2008 in Uncategorized
  •   |  
  •   |  
  •   |  
  • Comments Off

Comments are closed.