Can I Have Multiple Hidden Views In A ViewController? - ipad

I know, this seems a bad solution, but I can't think or figured out how to make something better.
What I need to do is like a menu, iPad menu, with a toolbar up and bottom, and an image in the background. In the bottom toolbar, I'm going to have 4 different buttons. Every button is going to create the options menu in the middle of the screen. One button needs to display 3 options (buttons with images), another 4 options, another 8 options (for this, I'm going to use Scroll View and Page Control, because I'm going to need 2 pages), another 2 options.
I was trying to use subviews, one subview for every button, and I was added the options in the subviews. When I select one button, its subview was loaded, but when I tried to change its position and size, its buttons was missed, the subview was empty...
Now I'm going to have the 4 subviews in the ViewController, but hidden. When I select one button, the view is going to appear, and the others views are going to have hidden. This means, that all the subviews are going to have loaded. Is this convenient?
Is this method requires a lot of memory?
If somebody have another and better solution, I'll be completely grateful...
Thanks

Yes, you can have multiple hidden subviews within a view controller, but I don't think it's the most practical way of going about it.
You mention that the menus are to appear in the center of the screen. In this case, I think a better approach would be to create a separate view controller for each of your menus and then have your main view controller present them modally by using the view controller's modalPresentationStyle property. By doing this, you're saving yourself a ton of time by not having to write code that checks for which views are hidden and which aren't; you're letting the API do its job, so at most you'll need to implement a few methods such as dismissModalViewControllerAnimated:.
Check out Apple's documentation about UIViewController, and more specifically the section called "Presenting Another View Controller's Content".

Related

how to manage view controllers in a sequential pattern - swift

I'm trying to implement sth like images below. there are some views that should be displayed in a sequential order and a bar above them shows the flow of tasks.
as it is shown, first profile view should be displayed. when the user clicks on Go to Next View Button second view (price view) should be displayed. the top bar shows the current view where we are in it. I've tried PagingMenuController already to create a menu with views and then disable scrolling. but PagingMenuController loads all views at the same time and also i don't know how to go to next menu item within child views. now I'm thinking of a container view might be helpful but i didn't use container view so far and i don't know it's good for my purpose or not.
also i want that top bar without swiping between views (only on buttons) and one enable view at the same time.
any helps would be apprectiated.
Your question is both broad and vague. My answer is also going to be fairly high level. I suggest you follow my outline, and if you get stuck on a particular step, post your code, tell us about the problem you're having, and we can help you fix it.
This is pretty simple. Create custom view controller. Give it a container view at the bottom that would contain the current child view controller. Use view controller transition methods to switch between child view controllers. You'll want to add layout anchors to each new child view controllers to pin all of it's view's edges to the edges of the container view.
Create a custom control on top to show the dot and highlight the title of the current view controller.
If you want the next/previous buttons to be on the child view controllers, put them there, and add a delegate property to all the child view controllers that points to the parent view controller, with next and previous methods.
BTW, in languages, like English, where text is laid out from left to right, I would think your first page would be on the left and the last page would be on the right. (I think it makes more sense for profile to be on the left and pay on the right.)

How to implement swipe views with CollectionView/TableView Controllers?

I am creating an app using Swift, and I'm still trying to figure out what the best configuration would be.
What I'd like to have is 3 screens (the left screen would have a side out panel) that users can access via the navigation bar menu or just by swiping left/right the screen for more accessibility.
I could easily create my TableViewControllers/CollectionViewController and the menu, but I'm struggling at making the screen able to detect users gestures at the same time, and I'm not sure whether I should use 3 View Controllers and then add the Collection View/Table View via the Storyboard, or directly use the CollectionViewController/TableViewController
I added a picture here describing what I'd like to accomplish:
Also, I wonder whether I should use storyboards or not for my project.
I know that's a lot of questions !
Any ideas please ?
Thank you very much and have a good day,
J.
You need to add 2 "swipe gesture recogniser"s to your middle screen(your second screen in your attached image) , and set one for identifying left swipe and another for right swipe. Create action methods for both in your view controller and add code accessing left screen and right screen in respective methods.
note - you need to drag "swipe gesture recogniser" to top bar of your view controller scene to add it.
You can use a scrollview as a container, put three ViewController in it.

master controller with buttons needs to load pageviewcontroller. master buttons not accessible after first load

I am new to xcode and IOS (and this board. First post).
I am completely flummoxed by a design problem and unsure how to approach.
I have three buttons, each of which calls a new array of pages that need to navigate horizontally with swipe gestures and have their own buttons.
The three buttons in the parent work exactly like a tab bar except they have to be bigger and higher than a tab bar would be. The called page arrays mostly work like a pageviewcontroller except that the pages need to have a button/indicator below to allow non sequential navigation. The target HAS TO LOAD WITH A SEGUE.
The problem I'm encountering is that using a modal segue to load a pageviewcontroller and prepareForSegue to keep the master/parent view controller visible results in my buttons being inaccessible. I assume its because I cant click thought the child view controller.
Secondly, I don't know if its possible to customize the page indicator dots of a pageviewcontroller so they can look like a bar with graphics.
Here are my specific questions:
Is it possible to load a view controller with a modal segue and still access my buttons? Can the child be resized?
can i customize the buttons/indicators in a pageviewcontroller. Can you point me to some code?
should navigation like this be done with some completely different approach? What about a view controller container?
Here's a diagram (cant post images directly yet)
I've found the answer to my second question: It seems that pageViewController's indicators are not customizable in any way. This rules out pageViewController for what I need.
9 Views in 10 hours. Is this not the best forum for questions like this or is there something wrong with my post?

Define modal view dimensions ?

I am developping a Master-Detail based iApp and I would like a specific button in the Master pane to trigger the apparition of a "settings" Form Window.
I then set my segue as "modal" and I get a form view covering the whole screen. This form comes from the bottom of the screen.
How do I get my view to appear from a slot at the top of the window and to cover, say, 2-thirds of the screen width and 3-quarters of its height?
Thanks!
You can't readily do it using the modal presentation styles, as they are fixed sizes. It is possible to work around but you need to mess around with resizing private views and it quickly starts to feel a bit fragile and messy.
It's simpler to create your own view controller at whatever size you like, add it as a child view controller and animate it into position yourself. You can even add your own background dimming view.
You lose the convenience of segues and the dismissal code, as you're no longer "presenting" the new VC, but that's not hard to recreate.

Creating an animated slide-down menu using Autolayout

I'm trying to upgrade my app to use Autolayout, basically to be future-proof, but I'm running into a huge amount of problems TRYING to use autolayout.
What I have is a view controller which contains two UINavigationControllers (using view controller containment). If I press a button, I want the menu to come down. Within the menu, i'll push view controllers and whatever else, and if the user wants to quickly get out of the menu they can tap the bottom part of the view at the bottom. Basically, if you've used Uber, something similar to that.
I have fiddled and fiddled but I can't get it to work correctly. The best I got was set up a XIB for the container view, and have two views within it (as well as a few outlets for some constraints). Within code, I change the constants of these constraints to make the menu view move and to force the correct height of the menu (which is the same as the bottom minus an offset).
The problem comes in when I try to push another view controller in the menu as it seems to throw away the height constraint set on the menu -- new view controllers take up the entire screen. I don't want to use clipSubviews because that doesn't really solve the problem, and sometimes I use overlays which need to go outside of the view.
To be honest, I don't even really care that much if this animation even uses autolayout, but I want to be able to use it on the view controllers within each navigation controller. Right now, if I turn it on, the animation won't work at all.
Any ideas?

Resources