24453

how set content size of textView's Scrollview immediately when user starts scrolling or when ta

Question:

I have UITextView in that in include image/ (UIImageView ).

But when i want to see the image it is unable to see / scroll,

i implemented logic to increase the scroll content size dynamically with respective to the text size,

- (void)scrollViewDidScroll:(UIScrollView *)scrollview { if (scrollview.contentOffset.y >= scrollview.contentSize.height - scrollview.frame.size.height) { CGSize s = [messageView.text sizeWithFont:[UIFont systemFontOfSize:25] //define your textview font size constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, MAXFLOAT) // - 40 For cell padding lineBreakMode:UILineBreakModeWordWrap]; // To increase the text view scroll content to display image also [scrollview setContentSize:CGSizeMake(200, s.height+150)]; } }

but it starts scrolling only when text in the text view exceeds its (textview) bounds.

I was <strong>unable to see the full image if the text is with in bounds (no of lines can fit in text view)</strong>

<strong>How to set scroll size when touch / starts scrolling on textview</strong>,,

Answer1:

use this code after set the text to the messageView(UITextView)

messageView.frame = CGRectMake(messageView.frame.origin.x, messageView.frame.origin.y, messageView.frame.size.width, messageView.contentSize.height + 150); float fscrview = messageView.frame.origin.y + messageView.frame.size.height + 150; scrollview.contentSize=CGSizeMake(320, fscrview);

Recommend

  • How to listen to the scrolling event of scrollviewer in windows phone 8?
  • How can I redirect pan gesture events to parent views?
  • iOS WKWebView detect when reaches bottom
  • Cannot use respondsToSelector using ARC on Mac
  • iOS WKWebView detect when reaches bottom
  • How can I use a UIScrollView to change values, just like a UISlider?
  • How to enforce horizontal scrolling on UITextView?
  • Enable UITableView scrolling during a scroll in UIScrollView
  • how to get correct hight when we have some content on UIWebView in swift iOS?
  • Tableview button selection wrong after search
  • Manage UITextField's dynamic position using auto layout
  • How to Convert a CCSprite image to UIImage?
  • Get touch points in UIScrollView through UITapGestureRecognizer
  • Can I put a UIScrollView inside another UIScrollView
  • UiTableView header not disappearing
  • Localization using resources file not working
  • setContentOffset on UIScrollView the right way
  • UICollection View causes “UICollectionViewFlowLayoutBreakForInvalidSizes” on smaller devices
  • Generating prime numbers between m and n [duplicate]
  • Disable vertical scroll in UIScrollView Swift
  • Simultaneous accesses to 0x10f10df48, but modification requires exclusive access
  • Extract java script from html document using regular expression
  • How get size between tableView and tabBar?
  • I can't show LinearLayout at bottom to scroll view
  • UIScrollView - setting proper contentOffset for new contentSize yields undesirable empty space
  • How to Update UILabel from Another ViewController
  • UIPageViewController delegate method similar to scrollViewDidScroll:(UIScrollview*)scrollview
  • Macros: knownDirectSubclasses broken with nested type?
  • Setting attributes of an EditText added dynamically in Android
  • Delphi: Where is the shortcut that started the application? [duplicate]
  • unknown Exception android
  • EntityFramework adding new object to nested object collection
  • Checking variable from a different class in C#
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • failed to connect to specific WiFi in android programmatically
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • How can I use threading to 'tick' a timer to be accessed by other threads?