I'm creating a full screen image viewer for my app (i.e. click on a thumbnail and a full-screen viewer opens up that allows for zooming (UIScrollView) and swiping to the next image). I'm currently presenting the UIPageViewController as a modal view. I can't seem to figure out how I can place a "Close" button on the screen so I can dismiss this modal view. I tried to include the "Close" button on the UIPageViewController's content pages but these items move with each swipe (as they are supposed to). So, how can i create a button that sits above the UIPageViewController and allows me to close this view?
Seems like a simple issue but can't seem to find a good solution.
Instead of adding the UIButton to the UIPageViewController which as you stated would move along with page swipes, do this:
Create a UIView
add the UIPVC to the newly created view as a subview
also add the UIButton to that newly created view as a subview too.
Now you have two subviews in this newly created UIView and they would be separate views that you can interact with without it affecting the other
What you were doing before was adding the UIButton to the UIPVC which is not what you want as explained in the opening paragraph
Related
I am new to swift and iOS development. I have created a scroll view with table view cells and image views inside cells. Each Image view has a button with same constraints. I have a fixed button in the same screen (irrespective of scroll view) and I am not sure how to achieve the click for it since every time I click on it, the background button is being clicked. I saw some solutions about disabling and enabling the buttons but in this case, I will not be sure which button will be in the background since it is a scroll view. Any help on how to solve this will be appreciated
Since I don't see your code, I can't tell you the exact fix but I assume that the question is how to determine the button's position in the parent view hierarchy. Every UIView has a method called bringSubviewToFront(view:) so if this was the case, then, you can use this method to bring your button to the front.
I'm made on-boarding screen with PageViewController for sliding and ReviewViewController as ViewController for content.
Every time when i slide a page I create new ReviewViewController with right content inside.
On ReviewViewController I've got Image, Label and PageControl
Everything works good But - when I slide a to the next page - PageControl slide out like image or label, but I want to fix it and change only color.
One more time - when i slide every elements slide out, I want to fix PageControl always on the same position on the screen
Please give advise.
You can achieve this using a container view. Rather than making the UIPageViewController the rootViewController of your UINavigationController, add an intermediate UIViewController that has a container view subview, and add the UIPageControl as a sibling.
You should remove the UIPageControl from your sub view controllers.
You'll need to add some way of propagating page updates back to the UIPageControl - a delegate protocol or closures will work nicely for this.
I've an instance of UIPageViewController in my project with an iPhone picture showing different sceneries as user scrolls.
I want a "fixed-background scrolling layout" i.e when the user scrolls, the iPhone-picture should remain fixed but only the sceneries inside it should change. How could I do that?
For example: In https://sdslabs.co/#muzi, as you scroll down the Mac-picture is fixed but the picture inside it changes.
Another example can be seen in the 'Numerous' iOS app.
I am assuming that you know how to implement UIPageViewController. I am just explaining how to design your Layout to achieve this.
In your FirstViewController's View add a UIImageView containing iPhone's background in which your images will change on scrolling. Add another UIView as a sibling of your UIImageView and add ContainerView in it. Your PageViewController will be embedded in your Container View.
I have a Scroll View with a View (content view) inside of it. I've added two buttons to test. The Scroll View scrolls fine but the buttons within the content view are not clickable. I've seen plenty of posts saying this issue happens when they programmatically add UIButtons to the View, but I am not doing this. Here is my exact process:
Drag the Scroll View onto the main view. Add 4 constraints
Drag the Content View onto the Scroll View. Add 4 constraints.
Add 2 Buttons (one high and one low to test scrolling) to the Content View.
This is all I am doing, no code at this point. Is there anything else I have to do to allow the buttons to be clicked? Here is a screenshot of my xib:
Update:
When hooking the button up to a simple IBAction and logging a message, it turns out it IS being pushed and working properly. However, when the button is pushed, the button isn't changing colors like it should (its "pressed" state is not appearing). Any ideas why?
First make the button to custom type
Select button from storyboard then on right attributed inspector change its "state config" to whatever you need like Highlighted, selected, Disabled and default and choose the colour for each state.
Now you can see the colour change on that button.
A UIScrollView first needs to know whether or not you are going to scroll before letting the touch pass to its child views. If you want the child views to get the touch immediately, set the UIScrollView's delaysContentTouches to NO.
I am struggling with how to set up the following view arrangement. Not sure what viewcontrollers I should use. Should I use a container view (I'm only supporting iOS6+)?
I have a screen that contains a mapview (and view controller) that is working great. I want to add a view to this screen that slides up from the bottom to partially cover the mapview. This subview will be a scrollview and will have a small handle that is visible even when closed that a user can drag up to open or down to close. When this drawer view is open, the user can "page" left and right through a list of objects and the map will update accordingly.
I don't need any help with the map view or scroll view individually, only how the generate this screen with the multiple views.
Everything I have done thus far is via Interface Builder.
Thanks!
You could create a empty xib (UIViewController) and add this Xib file as subview of the main view. Next add a gesture recognizer to the main view (https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizer_basics/GestureRecognizer_basics.html), on the right gesture slide the subview up (http://www.raywenderlich.com/2454/uiview-tutorial-for-ios-how-to-use-uiview-animation).