I am using a UIPageViewController to display certain content. I want to be able to display additional content when the user pulls down on the page using a UIPanGestureRecognizer. I can't seem to figure out what I should add my gesture recognizer to such that it does not cancel any of the pageviewcontroller's actions.
One of the apps I worked on has functionality similar to this. It shows a full-screen UIPageViewController, but if the user drags down on a ribbon on the top right corner, it will slide the whole thing down to reveal a view behind (for settings and other stuff).
I think your problem is that the built-in gesture recognizers are for the page turns. So what you'd want to do is either have something to drag on (such as the ribbon on the top left in my app) that will have its own gestures. OR you can iterate through the gesture recognizers that are assigned to UIPageViewController and get the one that matches the PanGesture, then override it with your own functionality to either delegate the event to the UIPageViewController or do the slide down, based on the type of pan.
Hope that helps.
Related
How can I implement swipe to see more options? There are lot of libraries that I could readily use, but they all are designed for iPhone apps. In iPad you have a lot of space, and I want to stack the buttons vertically instead of horizontally.
Is there any library for this? If not, how should I go about building this as a custom cell?
I tried building a custom UITableViewCell class which adds a UIScrollView, but it's not the same as showing the buttons beneath the cell.
Based on your inputs I have created a simple custom cell with basic functionality of swipe to see utility buttons and of course buttons stacked vertically.
What I did was, add a UIView beneath the cell's content view and positioned at right. Now depending on the number of buttons provided each button's height is adjusted accordingly. And delegates are provided for button clicks.
Swipe gestures are added. On swiping left it will animate and shift the cell's content view to reveal the button view. On swiping right it will reset the cell to original position.
You can customise it from here onwards as you wish :)
I have uploaded them over here : https://github.com/srikanth-vm/GSSwipeableCell
I want to create a hidden page on top of main screen (like iOS 6 news feed) and a button at the top-right corner. When people push it or hold it and swipe toward downside, the hidden menu will appear. Honestly I don't have any idea about it.
If you want to have more complex events than just a tap on a button you should be looking at using a UIGestureRecognizer. For the types of interactions you're describing you will likely need 2 recognizers - UILongPressGestureRecognizer for the tap and hold, and then a UIPanGestureRecognizer for the downwards swipe. You might be able to use a UISwipeGestureRecognizer rather than the pan but I'm not sure if a swipe needs to start with an independent tap from the long press.
Good resources for learning about gestures are:
Gesture Recognizer Basics - Apple
UIGestureRecognizer Tutorial from raywenderlich.com
I am trying to figure out how to keep the textfield about the keyboard in IOS. I tried the different code on stackoverflow but none works perfectly. Like if the textfield is above the keyboard and I click on the field, it does not move up. How can I show the textfield above the keyboard at all times? thanks!
lakesh's link is an excellent resource to look at.
There are essentially two ways to handle the situation.
Method 1:
You can encapsulate your view inside a UIScrollView and when the keyboard pops up, you should scroll your entire view up an equal distance to account for the space taken up by the keyboard.
Method 2:
Take the ultimate parent UIView inside your current UIViewController and change its frame (ideally with an animation) so that it moves off the top of the screen and makes way for the keyboard.
As a general guide, Method 1 is the preferred method. This is because you can still access the UI 'higher up' in the UIScrollView by scrolling up to it (consider say, a form with multiple fields). In Method 2 the user cannot return to the other elements in the view without the keyboard first being dismissed. Of course, it may be that you don't need to see the rest of the view while accepting keyboard input, but that decision is up to you.
I have a subview with a UIButton added to a UIScrollView.
The button is working perfectly as long as the user isn't scrolling.
If the UIScrollView is still scrolling when the user clicks on the button, it just stops the scrolling instead(like if a row had been clicked).
Anyone know how to fix this?
First, make sure this really is the behavior you want - iOS users are used to scrolling views and touching to stop them with a tap without triggering button presses. Non-standard behavior (even when you think its better then the standard behavior) can be confusing to users used to how things work in other iOS apps - it can violate their mental model. Ok, note of caution over.
So how do you fix this? UIScrollView delays sending touch events until it knows if those touches are scroll events. You problem is a user tapping is a scroll event when the UIScrollView is moving. Two possible solutions:
Stop the UIScrollView from delaying any touch events it gets. You can set any scroll views delaysContentTouches to NO, which will stop the delaying action and should allow your buttons to be tapped while scrolling. You can read about it in the UIScrollView class documentation. You will also want to read up on canCancelContentTouches there as well.
Subclass the UIScrollView to add your own logic about where touch events should go. Here is a blog post that discusses how to do this.
My iPad (!!) app has a table view as the UISplitViewControllers details controller. To trigger various actions I use the following:
A swipe gesture on the cells to make a button visible that is called "Action".
Touching the action button shows a UIActionSheet with various options (Delete, Send, Download).
Touching one of the buttons in the action sheet triggers the action.
To achieve this behavior I customized the title of the "Delete" button which would normally be shown by the swipe gesture.
Please note that touching the cell itself will open/preview the touched item.
However, my test users complain that they cannot find the action menu because they would never try swiping the cells and if they would, they would do it to delete the entry. But they like that touching the cell previews the item.
Hence my question: what is the correct way of doing it? Show a disclosure button in every row (the little blue arrow to the right)? Show UIBarButtonItem in every row to bring up the action menu?
I'm so against it because it looks ridiculous to have a button in every row.
Sounds like a tricky situation; I'd either:
Add a detail disclosure button to each cell, and have that push a new view controller with the options (like the YouTube app).
Show the options in the "entry" view and have the "swipe" action an extra, discoverable feature (like the Twitter app).