UITextView starting from bottom - ios

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)];

Related

Why UIScrollView can not scroll once dragging UIButton or UILabel from storyboard

I got the same issue here
The UIScrollView can scroll when adding button or label via code, but failed when adding from the storyboard or xib.
Setting the contentSize from the viewDidAppear can resolve this issue.
Set up the contentSize from viewDidLoad can not work. Question here is to figure out why ? I hope someone can explain the insider magics or this is just a bug of UIScrollView. I think it should not be designer like this way.
The reason it doesn't work in ViewDidLoad is that all the sizes are not yet final there, in fact, Im betting it would also not work in viewWillAppear.Im guessing you are not liking making the change in viewDidAppear as it is visible to the user. The correct place to set the size is viewWillLayoutSubviews.
The flow is
viewDidLoad
viewWillAppear
viewDidLayoutSubviews
viewDidApear
I suggest you reread those methods in the documentation.

How to stop UITableView from clipping UITableViewCell contents in iOS 7

As I updated an app of mine from iOS6 to iOS7 I noticed that where in iOS6 cell content was allowed to cross outside of a cell when the clipsToBounds property is set to NO on the cells view or contentView, iOS7 seems to disable this even when the overall view, tableview, cell and cellcontent clipsToBounds are all set as NO. You can see a sample of this in the included images. The first is test code running on iOS6, and the second is the same code running on iOS7:
Does anyone know how to fix this issue? I'm guessing it's just a one-line fix, but I've spent several hours on this with no luck. To avoid a major rewrite and headaches I'd, but playing around with the view, tableview, cell and cellcontent clipsToBounds has been fruitless - all are set to NO still on iOS7, so I'm not sure what is happening differently.
You can see and download the sample project at: https://github.com/Jon-Schneider/ClipsToBoundsTest
Thanks!
It looks like the view hierarchy changed slightly in iOS 7 for table view cells.
You can try setting the clips to bounds on the contentView's superview:
[cell.contentView.superview setClipsToBounds:NO];
If you add the following to your sample code and run on ios7 vs ios6, you'll see there's an additional view between the cell view and content view:
[cell.contentView.superview setClipsToBounds:NO];
NSLog(#"%#", cell.contentView.superview);
NSLog(#"%#", cell.contentView.superview.superview);
NSLog(#"%#", cell);
if (self.view.clipsToBounds) {
NSLog(#"Master clips");
} else {
NSLog(#"Master no clip");
}
You may made chang in the tableview attributes inspector of Clip Subviews.

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

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..

Why does the UIScrollView could not be scrolled in the iOS simulator?

I'm trying to get familiar with the UIScrollView. I try to set the UIScrollView's contentSizeto full width of the screen and ten times the height of the screen in the corresponding ViewController's viewDidLoad method. However, when I tried to run it on the iOS simulator, I found that the view can't be scrolled. Please kindly help to give some hints & opinion.
Thanks!
You need To check in your Code See
1)Check whether the UserInteraction enabled For The UIScrollView if not Please Do as
[theScrollView setUserInteractionEnabled:YES];
EDIT
2)Please Make Sure You have Enabled The Scrolling of UIScrollView
theScrollView.scrollEnabled = YES;
Thanks.

UIScrollView layoutSubviews behavior changes in iOS 5?

I'm working on a component that is a subclass from UIView and contains a UIScrollView.
When scrolling, I noticed different behaviors depending on which SDK I build with. On iOS 4 the layoutSubviews message is send on the scroll view's superview (which is my component) but on iOS 5 it seems that the message is not send anymore...
After taking a look at the iOS 5 release notes and changelog, I did not find any mention of such a change. Did I miss somethin?
In iOS5, layoutSubviews is not called on a scrollView's superview. But it was in iOS4.
If you want this behavior in iOS5, do this in your subclass of UIScrollView:
- (void)layoutSubviews {
[super layoutSubviews];
// causes layoutSubviews to get called on superview
[self.superview setNeedsLayout];
This was probably changed to be more efficient. Just because UIScrollView is scrolling, doesn't mean it's superview needs to layout itself.
I had big probs with resizing the size of button witch was subview in tableview. The nib loaded the smaller button and after loading I resize it. But the table view content didn't. (In iOS 4.* it was perfect but in iOS 5). So I figured out that I have to place my resizing in ViewDidLoad. I hope it helps to some1 =)

Resources