iPhone iPad UIView controller popup centered - iphone

My application is for iPad.
I have a UIViewController as the main view of my application.
I have an UIView at the bottom as a footer, and inside 3 UIView (subviews).
My 3 subviews in the footer banner load for each a different UIViewController and display the view of this controller into their view.
I would like when I click on a button into one of this subview (button that belongs to my UIViewController, with a 240x162px view), to make the subview disappear and display a centered popup (500x350px) with an animation into my main view.
To show you an example, WeatherBug for iPad has what I want, when you click on a block on top, the little view flip and a zoom effect is done, that display a centered uiview with more content.
Please tell me where I should look for!
Thank you,

Use the delegate pattern. Assign your "root" view controller as the delegate for your "footer" view controller. When the button is tapped (no clicking on the iPhone), the "footer" view controller will hide the banner, then call a delegate method to handle the tap action; in this case, the "root" view controller then shows your centered popup. When the popup is done, the "root" view controller then tells the "footer" view controller go show the banner again and go back to normal.

Related

Presenting a UIVIew from a container view modally (nav bar missing)

I am a bit new to iPhone development and working on learning it on my own.
I have a view controller which contains 2 parts:
Image View - some picture + some text on top of it
Container view
the container view is now segued into a new controller view which I replaced with a collection view. The idea here is for this to hold some picture I can click on to get to another page yet.
So, with all that, I have things working fine. My main view shows the top picture + text and below is all the smaller pictures which are clickable and that take me to another view that is being presented modally.
The final view is a UIView that contains in it a imageView to hold the picture I clicked on the other view. This even works fine.
The issue is that I am trying to add a naviagtion bar on top of the new view which shows up fine in story board and I added a button to close it. But that for some reason does not show up when I run the application.
If I change the presenting mode to Push, I see the navigation bar show up with the back button as well, but my close button does not work there either (code added to dismiss the view correctly).
What am I doing wrong with the modal presentation?
If you want to present a view with a navbar modally, it has to have it own NavigationController.
So too have a NavigationBar in a modal displayed View, drag a UINavigationViewController in front of your ViewController, e.g.:
This is not needed in case of a push segue, as the pushed ViewController is still child of the original UINavigationViewController, wich is owner of the NavigationBar
The NavigationBar is managed by the UINavigationController, wich is on the parent-side.
So if you add Buttons in the Storyboard, you are adding these buttons to the NavigationItem, wich belongs to the ViewController.

Display whole ViewController within another ViewController's view

Im writing an application which the main view controller is a UIViewController. It has some icons in a grid and I want to dismiss (sliding down) this grid when one of the icons is clicked. This I've done already. The problem is: when the grid is dismisseed I want another View to come from the top of the screen. This view is in this same root view controller. But I want to display the content of other view controllers in this view. For example: I want this view to show a UINavigationController with a UITableView inside it, so the user can navigate through TableViews.
I'm doing this:
HorariosViewController *horarios = [[HorariosViewController alloc] init];
[vuashView addSubview:horarios.view];
HorariosViewController is a UINavigationViewController. It shows me only a blue NavigationBar and changes like self.navigationItem.title = #"Title" won't work.
Thanks!
You can show another view controller's views as subviews but their outlets and actions remain linked to their original view controller unless you write code to make new connections, so self.whatever shouldn't be expected to affect the other view controller's properties.
(Also, if HorariosViewController is a UINavigationController, it shouldn't be created as a UIViewController.)
One approach is to have the navigation controller already there, with the icon grid presented modally on top of it. (you can set the view up this way without animations, so the user doesn't see the navigation controller underneath).
Then, when it's time for the grid to go away, it can call dismissModalViewController on itself with animation.

iPhone Dev - Scrolling to a new position in a tableview that is currently off-screen

Say for example I have a tab bar controller where one of its views is a tableviewcontroller, and another one is some other view. The other view has a button in it that when pressed, should make it so the tableview (which is not on the screen while you're pressing the button) repositions itself so that some specified cell is now the top one being displayed when the tableview is again displayed.
My question is this: can I just call [myTableVC.tableView scrollToRowAtIndexPath:someIndex] from inside the other class when the button is pushed? Or does the view actually have to be on the screen when scrollToRowAtIndexPath is called for it to change the top cell that will be displayed?
You may be able to, but you probably shouldn’t—calling view or tableView on an offscreen view controller may cause its view to get loaded into memory unnecessarily. Just set a property—a CGFloat or whatever—on the view controller for the scroll position that it should be at when it appears, and scroll to that position in the controller’s -viewDidLoad or -viewWillAppear:animated:.

How Can I hide an info button from a subview?

I have a mainViewController and inside its nib file I added an info button, in which action is to flip between two subviews, subview A and subview B.
From mainViewController, under viewDidLoad, I'm inserting subview A. Here I notice that the info button is in front of the subview A, which is fine.
The problem comes that when pressing any buttons that are located within subview A's nib file, in which they add new subviews, the info button remains on front.
So, how can I add these later subviews on front of all parent view stacks, so the info button does not appear? or how can I hide the info button?
If I understand correctly, your mainViewController's view has two superviews: subView A and infoButton. You'd like to add subviews to subviewA that appear over the infoButton view?
The simple answer is that you can't make subviews of subviewA appear over the infoButton view. If you think of the view hierarchy as a tree, the renderer draws the views in a depth-first way. This means it draws subviewA, and all of subviewA's subviews (and so on) before it considers the infoButton view. If you want a view to appear over the infoButton view you need to add it as a sibling of infoButton after infoButton in the main view's subview list.
If you'd like to hide the infoButton, you can simply set the hidden property to YES, and then set it to NO when you want the infoButton view to reappear, of course.
Depending on what you're doing with subviewA, you might consider using a modal view controller or a navigation controller to manage the views that you add when the user interacts with subviewA.

Non-Modal view without NavigationController

I have an app built from the UITabBarController starter project. The first tab is part of the main.xib that contains the tab bar. I would like to slide a view up from the bottom on top of that tab's view that only covers part of the screen. My understanding is that you can only cover part of the screen if you make the top view non-modal, but I don't see a way to do that without a NavigationController.
How can I do this?
you can add a UIView as a subview to the current view, and then animate its appearance into the screen using animation blocks, or Quartz or however you would like.
presentModalViewController: is actually a method that belongs to UIViewController, the superclass of UINavigationController, so you can use it from any view controller, not just a navigation controller.
Have you tried using a UIActionSheet? That's an easy way to get a view with a few buttons for user input to slide up and only cover the bottom portion of the current view.