3

I have UIScroll that have uitextview inside it.

My apps look like this:

rootviewcontroller -> PhoneContentController (UIScrollView and PageControl) -> DetailController (UITextView, UIWebView, UILabel).

My Flow is like this:

Set UIScrollView default size -> call DetailController (calculate UITextView and other page inside it in viewDidLoad) -> PhoneContentController get the total height size from DetailController-> Change the height of UIScrollView

This is the code in PhoneContentController (loadSCrollViewWithPage):

scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * kNumberOfPages, [detailController.getTotalHeight]);

The code in Detail Controller (viewDidLoad):

summaryBlogParsed = [summaryBlogParsed stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[self.itemSummaryText setText:summaryBlogParsed];

CGRect frameTextView = self.itemSummaryText.frame;    

frameTextView.size.height = self.itemSummaryText.contentSize.height;

self.itemSummaryText.frame = frameTextView;

This code in DetailController getTotalHeight:

 CGRect cgRect = [[UIScreen mainScreen] bounds];

CGFloat scrollFrame = (cgRect.size.height/2) + itemSummaryText.frame.size.height;

                       return scrollFrame;

I can scroll the scrollview but the textview not load all of the string. like only half of it, but i can scroll down but with blank pages :(.

Anyone can help me?

Thank you

chown
  • 51,908
  • 16
  • 134
  • 170
edric_s
  • 227
  • 3
  • 11
  • Could you please try to explain this sentence in more detail, I don't know what you expect should happen and what actually happens: "I can scroll the scrollview but the textview not load all of the string. like only half of it, but i can scroll down but with blank pages :(." – Mattias Farnemyhr Dec 13 '12 at 16:24

2 Answers2

0

set content size of scroll view using this function.

-(void)setContentSizeOfScrollView:(UIScrollView*)scroll
{
    CGRect rect = CGRectZero;

    for(UIView * vv in [scroll subviews])
    {
        rect = CGRectUnion(rect, vv.frame);
    }

    [scroll setContentSize:CGSizeMake(rect.size.width, rect.size.height)];
}

after adding all controls to your scroll view call this function and pass yourScrollView as argument. Hope this will help you.........

Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76
0

According to Apple... When debugging issues with text views, watch for this common pitfall:

Placing a text view inside of a scroll view. Text views handle their own scrolling. You should not embed text view objects in scroll views. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.