iOS connect my view to popup on button press - ios

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

Related

iOS popover with a close button outside

I need to create below thing
Currently i'm using WYPopover , but I can't create the button since it's outside of the popover. Is there any existing solution out there ? Many thanks
Create a bigger popover UIView holding all your child elements (current popover + button) and make its background transparent or however you wish.
Popover-controller's are exclusively used in iPad. If you want to use in iPhone, you should create it in a custom way.
I am not familiar with the XYPopover in Github, but normally the custom created popover should be dismissed whenever the user taps any place in the screen. That is one of the key feature of the popovers.
Normally the custom popovers are build like, adding a hidden parent view and then the visible image of a popover frame on it.
You should to do the following,
Avoid dismissing the parent view on tap of parent-hidden-view.
Add a close button at the area where you want to show the close button, on top of the parent-hidden-view.
Capture the button click and dismiss the view (remove the view from superview)
How to customize your need
Creating custom popover view is not a big task. It will take maxim one day, try it your self.
One Parent view with clear color
One background image of a popover frame.
View-inside popover (this needs to be customized for UIPopover also).
Close button.

using UIReferenceLibraryViewController in custom popover controller

I am using custom popover controller(WYPopoverController) for iPhone and showing UIReferenceLibraryViewController in it. The view does come perfectly but UIReferenceLibraryViewController has 'Done' button on its navigation bar and when I click on it, it does not respond. Though if I click outside the popover then popover disappears. I simply want to disappear popover when 'Done' button is pressed.
Please note, if I use UIPopoverController for iPad, then 'Done' button in UIReferenceLibraryViewController does respond. Not sure what am I missing in custom implementation.
Any help is much appreciated.
The problem to me seems like part of a terrible design by Apple, where the reference library controller dismisses itself rather than providing a delegate method notifying you to dismiss it. First, open a bug report with Apple and post the bug report number so people can duplicate it.
In absence of better options, I would suggest replacing the controller's navigation item's bar button item with your own, where that button would notify you of the user's tap and you'd dismiss the controller properly. This is a partial solution, as the reference library controller is a complex case, where it maintains a navigation stack internally. You may have to dig in the view controller parent/child hierarchy to find all cases.
Consider changing your design in the meantime, presenting the view modally instead of a popover on phone/pod devices.

Swap/ Transitioning between views iOS programming

I am a newbie to IOS programming and currently i have a tab bar application with two tabs. I have two questions.
The first tab shows a map, imagine it with some pushpins. There is a button on the navigation bar and when this is clicked i want the map view to to move out and a list view to come in. You can see the UI from the image. The button is called list.
Now when i click list I want this view to go away and the list view to come in. So here are my questions ?
1) How do i do this ? I tried the navigation model but i don't want that because I do not want a back button. I tried to make two different views and just dragged the button to that view but the app crashes. I just want the list button on the nab bar and when clicked the view changes to the list view and the button text changes to map. So now if I click the button again it should go back to the map view and the button changes to list.
2) How do i achieve the animations for this ? Ive seen some app where the page flips around and I've seen some options like reducing the opacity etc but I want to achieve the flip animation.
Thank You for any help I get. I really appreciate it.
Interface Builder can do most of this. Hold down the control key and drag from your map View Controller's UIBarButtonItem titled "List" to your list View Controller, then choose the Action Segue "modal". An arrow appears representing the segue; click on it and use the Attributes Inspector to change the Transition to "Flip Horizontal". Here's a video
Or, you could do this programmatically with presentViewController:animated:completion.
Now to get back to the map from the list, I believe that must be done programatically. Create a method that calls dismissViewControllerAnimated:completion: and make your list View Controller's UIBarButtonItem titled "Map" trigger it.
After reading your comments, I am wondering... if the structure of your app is logically a tabbed app structure (as indeed you refer to it as a 'tab bar application'), shouldn't you consider using the UITabViewController instead of a NavigationController? That is what it is designed to do, after all.
If you do use a TabViewController you should reconsider your desire for flip animation, as that doesn't really make UI-sense for tabs. If you can dispense with the flip animation, TabViewController could be a good way to go and you should at least experiment with that before dismissing the idea. It is also designed to grow... you can incorporate any number of tabs in a tab bar. Check out the apple docs (with pictures!)
You will notice that tabs are at the foot of the screen, whereas your 'tab' navController buttons are in a navbar at the top of the screen. This also helps as your app grows, as it is straightforward - from a UI design point of view and programmatically - to incorporate navControllers as navigation tools within individual tabs. For example, if your map/list flip routine does indeed make sense for this part of you app, you can keep this as a single tab (in it's own navigationController) and add other tabs for other parts of the app...
update
From your comment, you are saying that you are interested in the navController-inside-tabBarController setup. In this case here are some ways to get flip transitions AND no back button..
(1) modal presentation
The easiest way to get what you want is to set up one of your viewControllers (say the map view) to present the other one (the list view) modally.
If in the storyboard:
embed your mapViewController in a navController with a navbar button for navigation to the listView as in your picture
add your listViewController to the storyboard and embed it in it's own navContoller (not the mapViewController's navController). Drag a barButtonItem to this navController and wire it up to an IBAction in listViewController
CTRL-drag from mapViewController's 'list' button to the listViewController to create a segue. Select the segue and in the attributes inspector set the segue type to 'modal', with transition 'flips horizontal' and 'animated' checked. Give it a name in case you want to refer to it in code.
in the listViewController's IBAction add this:
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
That should achieve your result. You can use the completion block to send information back from the list view to the map view, and/or set the map view as the listView's delegate.
If you are not using the storyboard check this apple guide
Presenting View Controllers from Other View Controllers
especially "Presenting a View Controller and Choosing a Transition Style".
There is one catch with this approach - when the presented view flips onto the screen, the entire previous view, including the tab bar, is flipped out of the way. The idea is that this is a modal view which the user is required to dismiss before doing anything else in the app.
(2) push/pop in a single navController If this does not suit your intent, you can navigate using a single NavigationController with push and popping of views, and you can hide the back button ... but you really would need to keep the back button functionality as you do want to go back to the mapView, not on to a new map view.
To hide the back button try:
self.navigationItem.hidesBackButton = YES
in the uppermost viewControllers' viewDidLoad
Then you can add a barButtonItem in the xib/storyboard, with this kind of IBAction:
[self popViewControllerAnimated:NO]
or
[self popToRootViewControllerAnimated:NO]
You would have to construct the flip animation in code as it is not supported as a built-in with UINavigationController (best left as an exercise for the reader!)
(3) swapping views in a single viewController As ghettopia has suggested, you could use a single viewController inside a navController (or with a manually place navBar) and swap two views around using the UIView class methods
transitionFromView:toView:duration:options:animations:completion
transitionWithView:duration:options:animations:completion.
This could be a good simplifying solution as your list and map are essentially two views of the same data model.

Page curl modal segue : leave bottom bar on screen

I develop an app for iOS 5+ with storyboards (and ARC). I have a view controller with no status bar, a top navigation bar, a map in the middle, and a bottom toolbar with a button at the bottom right. I've linked the button to a modal VC via a page curl segue.
My problem is I would like the page curl effect to apply only to the map (just as iOS 5's map), or at least not to the bottom toolbar, so I can present/dismiss the modal VC with the same button of the bottom bar (I want it to be persistent). Right now, I can present it by pressing the button, but the toolbar goes up halfway of the screen with the whole view. I can dismiss it by touching the upper-left side of the screen but it's not really user friendly.
I can add the toolbar to the modal view controller, but that doesn't look nice...
Any ideas ?
Thanks.
A quick thought for you as I stumbled on this while looking for something else, but I would consider:
Putting the top section of the screen within a container view, then presenting the modal view from that. It will leave the bottom (toolbar area) clear.
Alternatively, instead of using the standard segue you could implement your own page curl, and/or using some of the open source projects that demonstrate how to do this.
You probably solved this long ago but perhaps this helps someone :)

Tabbar not showing in ios application

i am making one iOS tabbar application in that i have put 4 different tabs and whenever i click on 1 st tab and load another view after clicking of the first tab. After that when i press back button then tabbar is not displaying .So that i want hint that how can i show that
back the tabbar when we move from one tab from another and yes how i can use consistent the tabbar in whole application can you just guys help me on this i am new to iOS development.
here i am put the screen shot ...
here first screen is this one..
when i tap the video button that are first in the view then another window open
which are as under and see the tabbar is not there...
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Looking at your screen snapshots, do I correctly assume you're attempting to transition to the "Videos" scene by touching the big "Videos" button in the center of the "Home" scene (rather than touching the tab bar button at the bottom of the screen, which I assume works fine)? If that's the case, you need to have your button tell the view controller's tab bar controller that you want to change the index of the tab bar, and it takes care of it for you. You cannot do the transition using a segue (or at least not without a custom segue, which is even more complicated than the procedure I outline below). If you're changing the view some other way (e.g. using a standard segue or using presentViewController, pushViewController programmatically, etc.), your tab bar can disappear on you.
You later said:
when in video controller there is tabbar is there but i drag and connect to that then tabbar is disabled
Yes, that's true. You cannot use a segue from one of your big buttons to one of the tabs in your tab bar. (Or technically, if you wanted to use a segue, it would be a custom segue which would do something very much like my below code, though perhaps a tad more complicated.) So, rather than using a segue for your big button, you need to write an IBAction (connected to the big Videos button on the Home scene), that tells the tab bar to change its selection:
- (IBAction)clickedVideosButton:(id)sender
{
[self.tabBarController setSelectedIndex:1];
}
A couple of comments:
My answer was predicated on the assumption that your tab bar works as expected when you tap on the buttons of the tab bar, itself. If you tap the buttons at the bottom of the screen, do you transition to your other views correctly and preserve the tab bar? If so, my answer above should solve your issues in getting the big buttons to work. If not, though, then the problem rests elsewhere and you need to show us your code that might account for that (either you're something non-standard in the UITabBarControllerDelegate methods, or your viewDidLoad of the view is doing something nonstandard).
If I understand your user interface design right, you have the tab bar at the bottom as well as the big buttons in the middle, which presumably do the same thing. That is, no offense, a curious user interface design (duplicative buttons, requiring extra tap on a button, etc.). You might want to choose to either use either big buttons (in which you can retire the tab bar, eliminate the IBAction code I've provided above, and just use a nice simple navigation controller and push segues, for example), or just use the tab bar (and lose the home screen, lose the big buttons, etc.).
You also made reference to "press back button", and I don't see any "back" button on any of your screen snapshots. Do I infer that you have a navigation controller and you're doing a pushViewController or push segue somewhere? If you're doing something with back buttons, you might need to clarify your question further.

Resources