0

I am trying to create multiple views in my view-based iPhone app in Xcode 4. I have followed many tutorials and read many articles but none of them have worked. I figured out that they require a Navigation Controller. How can I create 2 views that are switched with a button without a Navigation Controller?

Thanks!

Ahan Malhotra
  • 195
  • 1
  • 4
  • 17

3 Answers3

1

I would use presentModalViewController. There are a ton of youtube videos on how to switch views, some of them don't have presentModalViewController so you have to watch the video to see if they write presentModalViewController in their code. I always use presentModalViewController.

Charlie Fish
  • 18,491
  • 19
  • 86
  • 179
0

you can create one additional view and keep it as a retained variable in your controller and on demand, you can do

[self.view addSubview:secondView];
//or  - to remove second view and show first view
[secondView removeFromSuperView];
Saurabh Passolia
  • 8,099
  • 1
  • 26
  • 41
  • I am new to iPhone development- Can you please explain how I would do that? Would I create a new view(including class files) and declare it in my ViewController.h? Thanks For Your Reply! – Ahan Malhotra Sep 18 '11 at 18:23
0

Why not use a UINavigationController but disable the navigation bar?

It's the easiest way to do it. And it will avoid many issues that can come about with incorrect view controller programming. Your users will never know the difference - there are no visual clues that you've done it that way.

Nigel Flack
  • 108
  • 1
  • 4