Question

I have two subviews of UIScrollView. One is textView and other is tableView. I made textview's height flexible based on its content, but I have one problem. If the text in the textview (which is parsed data) is small, there is a big gap between textview and tableview. Or if the text is too large then it covers the tableview. How can I keep the same gap between textview and tableview irrespective of the amount of content of text view? This is all done in IB. Thanks.

Was it helpful?

Solution

you must handle both textview and tableview position dynamically like ur text view height and y-axis is y-axis 10; height 40; now in tableview setframe:cgrectmake(your X coordinate, textview.frame.size.height+20)

so its always show same difference between textview and tableview if your textview height is 60 than tableview y point is 60+20

OTHER TIPS

- (void)loadView 
{    
    CGRect pagingScrollViewFrame = [self frameForPagingScrollView];
    pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame];
    pagingScrollView.pagingEnabled = YES;
    pagingScrollView.backgroundColor = [UIColor blackColor];
    pagingScrollView.showsVerticalScrollIndicator = NO;
    pagingScrollView.showsHorizontalScrollIndicator = NO;
    pagingScrollView.contentSize = CGSizeMake(pagingScrollViewFrame.size.width * [self imageCount],
                                              pagingScrollViewFrame.size.height);
    pagingScrollView.delegate = self;
    self.view = pagingScrollView;

}

- (CGRect)frameForPagingScrollView {
    CGRect frame = [[UIScreen mainScreen] bounds];
    frame.origin.x -= PADDING;
    frame.size.width += (2 * PADDING);
    return frame;
}

- (CGRect)frameForPageAtIndex:(NSUInteger)index {
    CGRect pagingScrollViewFrame = [self frameForPagingScrollView];

    CGRect pageFrame = pagingScrollViewFrame;
    pageFrame.size.width -= (2 * PADDING);
    pageFrame.origin.x = (pagingScrollViewFrame.size.width * index) + PADDING;
    return pageFrame;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top