Part of view with storyboard - ios

So I'm working on a Google Maps-app, and I want a certain behavior. When tapping a marker I want the "Detail View", displayed below to popup. If swiping that detail view up I want it to cover the whole screen and make "MORE DETAIL" appear. If swiping down, it will close it.
I just can't figure out how to implement this behavior. Container View? Just a regular UIView wit gesture recognizer? Modal segue?
I'm not asking for code, just some words to get me on the right track.
Edit: For anyone else looking for this kind of behavior, every answer below is perfectly fine. I went with the container view, since the detail view is doing some network requests and UITableView work.

Can be done with Pan gesture and I would say by having Parent ViewController (Container) and Child ViewController instead UIView. Let me know if you would need more help :)

go with UIView and UIGestureRecognizer, it would be faster and simpler. Modal segue does not cover the whole page as you want, and container view is too much work to put on just a simple thing

Related

Buttons inside container view does not work

I am a total noob developing iOS applications and I'm working in one right now.
I have set up my storyboard with a HomeViewController (main) and inside this, a container view, with another view controller embeded. This child view controller is outside the bounds of the view, and when a click a button in my HomeViewController it gets animated to the top of my app, showing this child with a cool animation. Everything is right.
In my child view controller I only have 3 buttons, and when they are displayed on the screen with this little animation, they are not usable. They don't trigger the action of the button being pressed nor they get "highlighted" with iOS style. Nothing happens.
I have been searching a lot about this, I have tried addChildViewController() on parent, didMove(toParentViewController: UIViewController) on child and I also have added it programmatically. When added programmatically it works OK but the view does not respect the animation, just being displayed in the screen without following the parent's container, which indeed moves with the animation.
What should I do next?
Thank you very much
Edit: My question does not seem to be a duplicate of UIView animations canceling any touch input
I'm using Spring library for the animations. Also, in that thread they are talking about user interaction being blocked while animation isn't finished. That is not my case. Animation is perfectly finished when trying the button interaction.
From my experience, there are two issues which cause this behavior most often:
Some of your container views have userInteractionEnabled set to false, or
Your container view frame is small and you're attempting to tap a button outside the frame of the container which won't work. Consider it like a window to the button and there's an invisible wall blocking touches.
Both of these are best debugged using the Xcode Debug View Hierarchy, or you can also try the Reveal app and see what's going on there.
Finally, this misbehavior was because the wrapping view in my container was smaller than the container, but as these two were out of screen I didn't realise at first. Making the wrapping view big enough to fit the child container was the solution.
Sorry because at last this was a stupid question.
Thank you all
If you use auto layout. You may check out your constraint is correct or not. Especially for biggerOrEqual and smallerOrEqual constraint still need a concrete constraint. eg:
width = 100#750
width <= superView.width#999
You should not forget the first constriant.

UIPageViewController with docking/pinning functionality

I've been using UIPageViewController with transitionStyle UIPageViewControllerTransitionStyleScroll in order to be able to easily move between views in my app.
I'm looking for a bit more functionality that I won't get from the UIPageViewController so I'm looking to make my own solution - perhaps still a subclass of UIPageViewController.
To explain the extra functionality I'll provide a scenario & a diagram:
In A the app is currently showing the first view controller. I then drag from right to left which will of course start to show the second viewcontroller as shown in B. If I stop panning before the point where the UIPageViewController decides whether or not to show the second view controller or go back to the first one I'd like it to instead show the second viewcontroller (taking up one third of the screen) instead of hiding it completely.
If I was to keep panning a bit further beyond the halfway point and then released I'd like the second view controller to take up two thirds of the screen, while the first view controller takes up one third.
That's essentially it. I'd appreciate any advice on how to go about doing this. I'm thinking I'll subclass UIPageViewController and override the delegate methods, but I'd really appreciate any advice on a better solution.
Many thanks
Maybe this could give you a hint or and inspiration. >>
http://www.raywenderlich.com/78568/create-slide-out-navigation-panel-swift

xcode - pageviewcontroller override gestureRecognizers

I have used page-based application example shipped with xcode to build my app. The page view controller works fine, however, I have such problem:
In each view controller representing page data, I have some buttons, and clicking it leads to another view controller's view. I use this to add the view to view hierachy:
[self.view addSubview: self.articleViewController.view];
articleViewController just has a scrollview inside and show some text data. The problem is, if I swipe the view to scroll up/down, when it reaches the end page view controller takes this gesture and move to previous/next page, which not what I want. I want articleViewController receives no gestures from page view controller but only scrolling itself.
Hopefully I described good enough..
How can I disable gestures in my articleViewController? I have tried to study this post: UIPageViewController Gesture recognizers but haven't figured it out to solve my problem.
An example project to illustrate the problem: https://dl.dropbox.com/u/43017476/PageTest.zip
I know you cited the same question, but I don't like the accepted answer. Check out this answer, which is a bit further down the same post. I had the same issue and adding the block of code from that answer to the end of my viewDidLoad in my UIPageViewController fixed the issue I was having.
Basically what's happening is that the UIPageViewController is consuming all of the touch events, so you need to remove certain UIGestureRecognizers from the UIPageViewController so that it doesn't respond to those. It might be a little trickier than the example I posted as that is just removing UITapGestureRecognizer, but it's the same basic concept. You need to make sure that the UIPageViewController only advances to the next page on a right->left swipe gesture, and not an up->down swipe gesture.
Check out the UISwipeGestureRecognizerDirection documentation.

Linking different views to tableview/viewcontroller without using a navigation controller

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: http://imgur.com/GM5eH
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.

Specific iPad modal view

Okay, I am still learning how to program and things are moving along quite well, but I have a question for the group about something that has been plaguing me:
How do I create a pop view where the background can still be seen? I mean, say my iPad view has 5 buttons on it, and I want a small square to pop up over where that button was, asking the user a question - how would i do that? Can I make a modal view with an invisible background? (I don't want a UIAlert BTW - I know that would solve my problem, but I am trying to learn how to do this with my own view)
Can anyone point me in the right direction?
You say "pop view" which makes me think you're describing a popover. Have you read the iPad Programming Guide, specifically, the section "Creating and Presenting a Popover"? It really is required reading in this case.
Are you showing the popover from a bar button? If so, you'll want to use presentPopoverFromBarButtonItem:permittedArrowDirections:animated:. If not, you'll need to identify a CGRect that represents the button (you can use its bounds), and then use presentPopoverFromRect:inView:permittedArrowDirections:animated:.
You do not want to obscure the button with the popover. When you show the popover using the above methods, the framework will take care of positioning the popover on-screen. Use the UIPopoverArrowDirectionAny for directions whenever possible.
If you actually want to show a modal view, you can create whatever view you want and then display it in such a way that the background is not fully obscured. Just set the modalPresentationStyle of the view controller to something like UIModalPresentationPageSheet.
You should create a custom UIView with the dimensions and content that you want to display. Then, you can place the custom UIView on screen by calling something like:
//where 'self' is the view controller currently visible and 'customView' is
//the view which has the question for the user. Don't forget to set the
//frame property on customView so that it knows the correct place to display.
[self.view addSubview:customView];
Hope this helps. Andrew

Resources