2015-05-05 7 views
0

Так что в основном у меня есть UIScrollView, и внутри него у меня есть UIView в качестве представления содержимого, в представлении прокрутки установлен пейджинг включен, внутри представления содержимого у меня есть представление UIImage сверху и снизу у меня есть UITextView, текстовое представление может иметь текст размером больше от собственной высоты, поэтому он должен прокручивать вот мой код.UITextView Прокрутка внутри пейджинга UIScrollView не работает

-(void)setUpMainScroller{  
if(MainScroller != nil) 
{ 
    [[self.MainScrollViewContainer viewWithTag:80] removeFromSuperview] ; 
} 

MainScroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.MainScrollViewContainer.frame.size.height)]; 
MainScroller.tag = 80 ; 
MainScroller.backgroundColor = [UIColor clearColor] ; 
MainScroller.showsHorizontalScrollIndicator = NO; 
MainScroller.delegate = self ; 
MainScroller.pagingEnabled = YES ; 
MainScroller.clipsToBounds = YES; 
MainScroller.delaysContentTouches = NO; 
CGFloat paperWidth = MainScroller.frame.size.width; 
NSDictionary * item = [elements objectAtIndex:selectedIndex] ; 
NSArray * temp = item[@"Sub"] ; 
NSUInteger numberOfPapers = [temp count]; 
count = (int)numberOfPapers ; 
CGFloat por =(self.view.frame.size.width-40)/(CGFloat)numberOfPapers; 
[self setupIndicatorWithPaperWidth:por andPaperCount:(int)numberOfPapers] ; 


for (NSUInteger i = 0; i < numberOfPapers; i++) { 
    CGFloat rest = self.MainScrollViewContainer.frame.size.height ; 
    CGFloat labl =rest - 140+15 ; 
    CGFloat contentheight = 140+15 + rest ; 
    UIView * content = [[UIView alloc] initWithFrame:CGRectMake(paperWidth*i, 0, self.view.frame.size.width, contentheight)] ; 
    content.clipsToBounds = YES ; 

     UIImageView * image = [[UIImageView alloc] initWithFrame:CGRectMake(20, 0, paperWidth-40, 140)]; 

     image.backgroundColor = [UIColor grayColor] ; 
    if(i == 0) 
     image.backgroundColor = [UIColor redColor] ; 
    else if (i==1) 
     image.backgroundColor = [UIColor blueColor] ; 
    else if(i ==2) 
     image.backgroundColor = [UIColor greenColor] ; 
    CGFloat imageheight = image.frame.size.height +15 ; 
    CGFloat labelheight = contentheight - imageheight ; 


    UITextView * textview= [[UITextView alloc] initWithFrame:CGRectMake(20 ,image.frame.origin.y + image.frame.size.height +15, paperWidth - 40 , 20)] ; 
    [textview setBackgroundColor:[UIColor grayColor]] ; 

    [textview setText:label.text]; 
    [textview setUserInteractionEnabled:YES] ; 
    textview.delegate = self ; 
    textview.contentSize = CGSizeMake(textview.bounds.size.width , textview.bounds.size.height+50) ; 

    [content addSubview:image] ; 

    [content addSubview:@"LONG TEXT"] ; 



    [MainScroller addSubview:content] ; 

    //[content bringSubviewToFront:textview] ; 

    [textview setScrollEnabled:YES]; 

      // [MainScroller addSubview:image]; 


} 
CGSize contentSize = CGSizeMake(paperWidth * numberOfPapers, MainScroller.bounds.size.height); 
MainScroller.contentSize = contentSize; 

[self.MainScrollViewContainer addSubview:MainScroller]; 

self.MainScrollViewContainer.scrollview =MainScroller ; 
[self.MainScrollViewContainer bringSubviewToFront:MainScroller];}} 

ответ

0

я был в состоянии исправить это путем удаления любого вида контейнера в главном окне прокрутки

Смежные вопросы