(iOS7) Scroll to cursor in UITextView in UITableView in UIScrollView - ios

I have a problem since I updated to iOS7.
I have base UIScrollView horizontally and there is UITableView on it
(looks like a navigation style).
And I addChild UITextView on UITableView not on the cells.
And it scrolled to UITextView's cursor when typing keyboard. And it works greatly until iOS 6 but not since updating iOS7.
How can I solve this problem?
Thanks.

Handle textViewDidChangeSelection in UITextViewDelegate:
- (void)textViewDidChangeSelection:(UITextView *)textView {
[textView scrollRangeToVisible:textView.selectedRange];
}
The exact solution depends on your application, you can handle by subclassing UITextView but I would prefer a decorator pattern here (on UITextViewDelegate protocol).
I hope it helps.

Have you created your XIBs in xCode4 and now trying to open it in xCode5?
If yes than please check your XIBs properly as Xcode5 updates older xCode 4.x XIBs and sometimes it results in a unpredicted output.. I faces the same issues when all my views just disappears after opening it in Xcode5..
Also do try to change the settings of the xib in File Inspector to open in xcode 4.x and view as ios6.1 and earlier and see if it changes anything..

Related

UITextView starting from bottom

I'm having trouble with a UITextView. I have seen other people have had this issue before, but whenever my app loads on my phone, all the UITextViews start from the bottom of their text and I have to scroll up.
I have tried numerous solutions but I need a solution to use on ONLY the Storyboard as I have some views without designated classes.
EDIT
I think this is happening when scrolling is enabled - so how do I have scrolling enabled but stop this from happening?
Can not reproduce your issue on iOS 9.2,but you may try this
Set contentOffset with Runtime Attribtues
I face same problem and I still cannot find a solution using Storyboard only.
However, using the code below can prevent your TextView auto start at bottom
If your TextView is in UIViewController
- (void)viewWillAppear:(BOOL)animated {
[self.myTextView setContentOffset:CGPointZero];
}
If your TextView is in UIView
- (void)layoutSubviews{
[self.myTextView setContentOffset:CGPointZero];
}
Hope this help
Have you tried something like:
[self.textView scrollRangeToVisible:NSMakeRange(0, 0)];

Button inside UITableViewCell prevents scrolling only in iOS8

I have a custom UIButton inside a custom UITableViewCell which was working on all versions and devices until I test it on iOS8.
When you try to scroll the table over the button it works (scrolls) on all devices and on all iOS versions except iOS8.
I for sure played with
_tableViewController.tableView.canCancelContentTouches=YES;
_tableViewController.tableView.delaysContentTouches=YES;
But nothing changes.
Did something change especially related to touches or scrollviews, or... on iOS8?
update
Strangely, replacing UIView with UIScrollView (adding the following codes to the viewcontroller) solved the problem. I still don't know why this is required in iOS8.
-(void)loadView{
UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,1,1)];
self.view=scrollView;
}

UIMenuController menu disappears automatically when there are multiple UITextView

I'm trying to make UIMenuController to display copy&paste menu when the UITextView got long pressed. It works if there is only one UITextView on the screen. However, if there are multiple UITextViews on the screen, long press on the active UITextView (The one is the firstResponder) triggers magnifying glass to be shown, when finger is released, the copy&paste menu is displayed, however, the menu is dismissed automatically in less than one second.
The following is the view hierarchy:
UIView -> UIImageView -> MyUIView -> UITextView
|__> MyUIView -> UITextView
I set userInteractionEnabled and editable of non-active UITextViews to NO. Any idea on how to make the copy&paste menu stay?
I am using Xcode 4.6.3 and test it on iPhone 4S with iOS 7.0
Apparently, whenever there's a change in firstResponder, UIMenuController gets dismissed!
In order to track the source of the change, if other, you can listen to UIMenuControllerWillHideMenuNotification and check who's dismissing the menu.
I found a solution. I didn't have enough details in the question, that's probably why there was no answers.
The key missing piece is that I subclassed UITextView and it overrides layoutSubviews (see buggy margin behavior with dynamically resizing UITextView). The solution is simply removing layoutSubviews function, and I used krafter's suggestion to address UITextView cut off issue.

Preventing autoscroll with UITextView embedded in UIScrollView on iOS 7

I've been using the technique of wrapping a UITextField in a UIScrollView to prevent autoscrolling, for details on this, see this discussion on SO:
Disable UIScrollView scrolling when UITextField becomes first responder
This has been working fine for some time now on iOS versions < 7. However, it no longer seems to work on iOS 7. Has anybody else encountered this? Has anybody found a fix?
Figured out what was happening ... I had code that was setting the contentOffset.y to 0.0f in certain cases ... but on iOS 7, that was causing the scroll view to scroll up too far, and it should be setting it to -64.0f. I mistakenly thought this was being caused by UIScrollView's autoscrolling behavior.

UITextView doesn't scroll to caret after becoming first responder on iOS 7

I have UITableViewCell and in this cell I have UITextView with some text. When I call becomeFirstResponder on iOS 6 then it works as expected and the table view scrolls to caret but this doesn't work on iOS 7.
I have also UITextFields in cells and it works fine with becomeFirstResponder on iOS 7. Just UITextView is a problem.
Is it a bug or what did they change?
I came up with my solution that utilizes a method (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated from UITableView and a method (CGRect)caretRectForPosition:(UITextPosition *)position from UITextInput and after doing some math with heights. I have achieved same behavior as on iOS 6. It is not so nice but it works.
If anyone will come with a better solution, let me know.

Resources