The problem I am encountering now is that there is a UITextView component in UIScrollView and that UITextView component will interfere the scrolling of UIScrollView, i.e. when a user's finger is on that UITextView to scroll the whole UIScrollView, the screen won't scroll. The content in the UITextView is dynamic, i.e. the size of UITextView component is dynamic. The worst case is the whole screen is occupied by the UITextView and users won't be able to scroll the screen at all.
The UITextView is disabled for editing. I choose UITextView instead of UILabel because I want to detect phone number & link in the supplied text and utilize the built-in function to invoke dialer and browser when users click the phone number or link.
Any suggestion about how I can solve this problem or any clue about why this happens are all appreciated! Thanks.
UITextView inherits from UIScroll view so it has a property scrollEnabled. Just put it to false!
If you are using a storyboard or nib file, select your UITextView and uncheck Scrolling Enabled in Interface Builder.
Otherwise, do this:
textView.scrollEnabled = NO;
Apart from the property scrollEnabled, you also have the property userInterationEnabled that disable(if you set it to FALSE/NO) any touch events on the view (scrolling included, of course). Hope it helps, specially for other situations cos in your case it makes the same effect as disabling the scroll.
Related
I have a strange issue , I have a page app in which one page I had used a UITextView, but when I tap on the UITextView it moves to the next page, can't write anything on it.
There is no issue when I use UIPageViewControllerTransitionStylePageCurl. The only issue is with UIPageViewControllerTransitionStyleScroll. Anyone know the solution? please help me
I ran into the same issue myself, and it appears that it's a consequence of some default behavior that occurs whenever a UITextField or UITextView becomes first responder inside a UIScrollView.
The solution to prevent your UITextView from scrolling the UIPageViewController is to first embed it into a UIScrollView instead of directly into a page's main view.
This works because when the UITextView becomes first responder it will search for the earliest superview in the view hierarchy that is of type UIScrollView, and it will scroll that scrollview to accommodate for the keyboard covering the screen. If you don't wrap the UITextView inside a UIScrollView, your UIPageViewController's internal UIScrollView will be chosen and scrolled, producing undesired behavior.
You can refer the link below..
UIPageViewControllerTransitionStylePageCurl - http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPageViewControllerClassReferenceClassRef/UIPageViewControllerClassReference.html
UIPageViewControllerTransitionStyleScroll - http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPageViewControllerClassReferenceClassRef/UIPageViewControllerClassReference.html
I have few other UI in my UIView and i have a UIButton on the top which i want to be hidden until unless the user scrolls to see the content on the very top and then display the UIButton.
Is there a way to implement this.
Thanks,
UIView (and thus everything sub-classing it) has a hidden property, this includes a UIButton. You can simply set this to YES/NO to hide/show something to the user.
After that the real question comes down to the show/hide criteria and how to measure it. If you are using a UIScrollView then you can add/implement UIScrollViewDelegate. This will give you methods like scrollViewDidScrollToTop: to check if the user scrolled to the top.
Keep track of the previous scroll offset so that with each scroll you can compute the delta, telling you whether the user scrolled up or down. With that, you can toggle the button's "hidden" property. Hope that helps.
I've got an UIScrollView with an UIImageView at the top and an UITableView.
inside every cell of the UITableView I've placed a UITextField
I would like to know how I can automatically scroll to the UITextField selected so that it doesn't go under the keyboard
I've already looked at this Get UITableView to scroll to the selected UITextField and Avoid Being Hidden by Keyboard but it doesn't works very well for my situation..
could you help me?
Thank You!
Check out Matt Gallagher's fantastic Sliding UITextFields around to avoid the keyboard. It ought to be just what you need. You can modify it to only scroll a specific element, or just leave it as is to scroll the whole superview.
I want to create a text display area (either UILabel or UITextView) in my iPhone app which (1) allows scrolling and (2) does not allow selection. I have tried the following techniques unsuccessfully:
Basic UILabel: Didn't allow
scrolling, and clipped text to the
bottom of UILabel space on screen.
Giant UILabel within a UIScrollView: the UILabel kept placing the text (vertically) at the center of the giant UILabel, so it often was outside of my UIScrollView.
UITextView: So far this approach has worked the best, because it scrolls and does not clip the text. I can even subclass UITextView to enable resizing the text to fit within the textview, and passing any touch events to the superview to detect taps & swipes. But, when the user taps and holds on the text itself, the text selection interface appears. I am not interested in this interface and it actually is distracting from the user's experience. I have tried to subclass canPerformAction:withSender:, but apparently this function is called after the tap event--not before it.
Does anyone know how to disable the text selection interface in UITextView, without also disabling scrolling?
Take option number 2, but set the numberOfLines property on your UILabel to 0. This will set the number of lines to 'unlimited' and prevent the vertical centring of the text.
Don't forget to set the lineBreakMode property to UILineBreakModeWordWrap so that your text doesn't run off the side of the UILabel.
Ok. I have made a custom cell for my table, and it contains a text view. When I have multiple lines in the text view, I can scroll up and down, but in doing this the table also scrolls. How can I stop this behaviour? If anyone needs parts of my code or further details, please just ask. I am more than willing.
Thank you for your help
I suggest you to move text edit (write) behavior to another view controller. If you need read-only functionality from it then just increase cell and textView height.
Did you try setting canCancelContentTouches to NO? It's a property of UIScrollView, from which UITableView inherits.
Your custom cell seems to pass on touch events to its container class as well as utilizing them itself. Did you implement any - touchesBegan:, - touchesMoved: or - touchesEnded:?
If you make use of a touch events, you should not pass them on in the responder chain.
When the text view has focus, set scrollEnabled=NO on the table view. You may have to manually remove focus from the text view and restore scrolling when a touch occurs outside the text view.