iPad modal form sheet takes up the whole screen anyways - ipad

I'm trying to create a form sheet modal on iPad, which should be a 540x620 modal view.
I've created a view controller with a NIB file whose view is a 540x620 sized UIView (with stuff on it).
I set the modal presentation style to UIModalPresentationFormSheet, and call presentModalViewController:animated: on the current view controller.
My view slides in from the bottom, but instead of being a form sheet, it takes up the whole screen (my view elements are all anchored in the top left of the screen).
Even stranger, when I dismiss it, all the UI that was "underneath" it, is all re-layed out to be in the center, in approximately a form sheet sized area in the center of the screen. Bizarro!
Anyone have any suggestions as to what could cause this behavior?
Thanks.

Figured this out. I was setting the modal presentation style on the parent view controller-- it needs to be set on the newly-created child controller. One needs to think of it as a property of the child, not something the parent controls.
I would delete this question, but figure I'll leave it as a signpost for the future wayward.

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.)

iOS table view in modal gets shorter every time view appears

Here's my set up:
I have a tab bar controller as my root view controller. In one tab, I present a modal on user action. The modal has a navigation controller, and view controller with a table view as it's root view controller. On another user action, I push another view controller. Every time I pop back to the table view, the content size seems to have shrunk. The table view gets shorter and shorter in appearance. This does not correlate to change in size of the table view. When I log i always get back the same tableView size and content size, but the content is getting eaten from below.
If understood properly, your setup follows this diagram:
Using exclusively Storyboard, Autolayout, the ViewLayoutAssistant.swift utility to emphasize views positions and sizes (what makes the crosshair), and exactly 0 lines of code, the odd behavior you describe above cannot be replicated.
As a solution, I propose you do just that: move your code to Storyboard, and bring-in your business logic in this flawless interface.

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.

don't want the modal view to move up on keyboard show

I have a viewcontroller from here I am getting a popover. From this popover i am presenting a view as modal view.
There is a textview in it. When editing begins, the entire modal view moves up (which usually people desire). But I do not want it that way.
Is there any way, i can block my modal view from moving up and down on keyboard show and hide ?
If I guessed correctly then you need to set
yourviewControler.modalPresentationStyle=UIModalPresentationPageSheet;
instead of what you are probably using right now
yourviewControler.modalPresentationStyle=UIModalPresentationFormSheet;

iOS connect my view to popup on button press

I have two xibs, one is my title screen with buttons, the other is a more specific window that should come up when one of the buttons is pressed.
This isn't switching the whole screen, just a popup window, where clicking outside of the bounds of that window will make it disappear leaving only my title screen remaining as it was visible behind this popup view. This is similar to my understanding of "modal views".
Anyway I do not quite get how to connect it to the button on my title screen. I have the views made in IB ready to go. I'm not sure if I have declared all objects to satisfaction yet.
From what I understand I think I need a UIViewController or something, but its all a pretty thick fog of information right now
insight appreciated, or links to proper noob sources would be helpful
Does your title screen have a view controller (or is your app delegate the main controller object)? You will want to add an IBAction to that object, connect the button to it, and then present your other view controller modally (or in a popover) from there.
A popover will appear in a small window with an arrow, and tapping outside will close it. A modal view controller typically slides up into place, and you have to press a cancel button to close it. This guide explains how to use a popover. Using a modal view controller is simple if you have a view controller: [myViewController presentModalViewController:nextViewController animated:YES].

Resources