1

I apologize in advance for not being able to efficiently describe my problem statement. But, I shall include a link to an image to better describe what I'm looking for. Basically I have a Viewcontroller with a TableView inside it and I have a toolbar on top with three bar button items on it. Now what, I want is to be able to have a functionality whereby the user taps on any of these buttons and we go to different views. Now, I would like a design where if possible I stay on the same screen and render the information in the tableview below depending on which button has been pressed. Visually, I'm trying to go for an effect where the button that is pressed is shown as being depressed and information is rendered and on pressing a different button a different view is rendered. I'm familiar with attaching different view controllers to all the buttons and then segueing into those viewers. However, I would like to know if there's a way in which I can stay on the same view controller and just use sub views. If there is, how can I do this from storyboards? Again,, I apologize for being verbose, my picture should hopefully be able to tell you what I'm trying to do.

The link to what I'm trying to achieve: https://i.sstatic.net/vPDr3.jpg

1
  • This sounds like you want a tab bar controller, or a custom container view controller. Commented Jan 24, 2013 at 3:50

1 Answer 1

1

Well, one basic solution is simply to add these other views in your controller. Now that subview is set to hidden on viewDidLoad:. Then just create an action, and show the subView. You can size that view however you want, and play around with the other view as well.

Now, there might be a better way to do this, but that is how I would do it.

EDIT - Concerning Apple's method on Calender

Now, I have never tried anything like this, so this is all theory.

First, you create three classes. Each with it's own custom view. This view should be the size you need it on the other (Main View). You can set the size to freeform in the Interface Builder.

Once you have that done, you head to your main view. That view will have the three buttons. Set an IBAction for each of those that creates an instance of each view and places it on the screen. (I am not sure how to accomplish this, but I am sure there is a way. Take a look here: Objective-c Adding subViews in my controller

You should dealloc each view after you head to another view as well for memory management.

Sign up to request clarification or add additional context in comments.

4 Comments

Hmm, I don't understand what exactly you're trying to say. To give you a better idea of the functionality I'm trying to achieve, look at the Calendar app on iOS. Essentially I want to echo what is done there with the 'Day', 'Month' and 'List Button'.So when you tap the day button, you switch over to a different view without really seguing into it?
Yes, I am not sure how that is done. But what I said in my answer is to add a subview and use the setHidden: property to hide and show views.
I think what Apple does is they create three custom views, and insert them through code. When you tap on a button they dealloc that view, and alloc another one.
Hmm,can you describe this in detail?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.