Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone SDK: Advancing from one view to another using a button tap

I want to make a really simple iphone app: one screen with a single button... when the button is tapped a new screen appears. That's it. No animations, nothing,

I've tried endlessly to make the NavBar sample project do this... and it works but only if I use a UINavigationController with a table that I can tap etc. I've tried all the skeleton projects in XCode too.

I thought I was done when I did this:

[[self navigationController] presentModalViewController:myViewController animated:YES];

But I couldn't do it without the UINavigationController. I just want a simple example.

Thanks so much!

like image 810
MrDatabase Avatar asked Jan 21 '26 02:01

MrDatabase


2 Answers

One way you could do this is to create a new UIView and then when the button is pressed add that new UIVIew as a subview, therefore making it what you see.

If you make the new view its own subclass of UIView you would do something like this.

LoginView *login = [[LoginView alloc] initWithFrame: rect];
[mainView addSubview: login];
like image 105
kdbdallas Avatar answered Jan 22 '26 16:01

kdbdallas


[self presentModalViewController:myViewController animated:NO];

Will pop up a new view, no animations, nothing. To get rid of it, inside myViewController:

[self dismissModalViewControllerAnimated:NO];

Though I reccomend you use the nice sliding animations (change NO to YES.) And yes, you can stack them up. I think this is better than creating a new UIView, but I may be wrong.

like image 26
Isaac Waller Avatar answered Jan 22 '26 18:01

Isaac Waller



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!