Solved

Iphone SDK Button Click Go to View

Posted on 2011-03-07
6
774 Views
Last Modified: 2012-05-11
Hi all,

I have an app (iphone) and on a view I already have a button and an action applied to it.

Right now, when you click the button an Alert message will show up.

Basically I just want to remove the Alert message code and replace it with some code that will link to a UIView.

How can I do that please?

THanks
0
Comment
Question by:error77
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:gawhemant
ID: 35065837
Hello ,
Example code :
In the following code i have two view one is login and another is forgot password.
on click of forgot password button i am performing following action
1)Remove login view from superview
2) Adding sub view as new forgot password view  in the same view.
-(IBAction)onForgot:(id)sender
{
      [loginView removeFromSuperview];
      forgotPasswordView.backgroundColor = [UIColor clearColor];  //optional depends on design
      [forgotPasswordEmailTextField becomeFirstResponder]; //requirement
      [self.view addSubview:forgotPasswordView];
}

If you want any other help tell me i am available.

Regards ,
Hemant
0
 

Author Comment

by:error77
ID: 35067959
So if I was to use something like this on it's own:

 [self.view addSubview:MyView];

would that work on it's own?

I find it really hard to do things the mac way.

On interface builder it would be great to add your buttons, then double click on the button and enter the code just there...

Just like every piece of software I've ever worked for. :o/

0
 
LVL 3

Expert Comment

by:gawhemant
ID: 35068394
Hello,

You want to switch from one view to another on click of the button.So you will need to create two views one will be displayed and one will be added as an subview on click of the button ie at IBAction

Regards
Hemant
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:error77
ID: 35068823
So the totally minimum code involved would be:

1. create 2 views
2. Add the buttons to the views on IB
3. add the IBAction to the .h files
4. add the IBAction code to the .m file with the    [self.view addSubview:MyView2]; in it.
5. link the buttons to the IBAction actions?

0
 
LVL 3

Accepted Solution

by:
gawhemant earned 500 total points
ID: 35068946
Yes This could work you can implement the similar code which i have given you for IBAction.
One more thing define those views as well in .h files.
in .h file
   IBOutlet UIView *firstView;
IBOutlet UIView *secondview;

Open in new window


And remove 1st on click of button and then addsubview.

Regards,
Hemant
0
 

Author Closing Comment

by:error77
ID: 35069168
Great! THanks
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Apple updates maxing Wi-Fi 14 120
Outlook iPhone Contacts 6 68
Shortcomings of iPhone's text message feature 4 88
How do I stop unwanted text messages on my iPhone? 9 81
iCloud Drive was introduced after iOS 8 was launched last year. This drive is Apple’s online storage device that lets users sync their files and access them from all their Apple devices.   There is a lot of data that is not automatically backed up…
Are you having trouble connecting or getting your iPhone / Samsung device(s) to sync with Microsoft Exchange Server?   What have you tried?   What haven't you tried?
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question