rockey
rockey

Reputation: 638

Scroll view with an image is not scrolling

i added an image to the scroll view. but its not scrolling... pls help out what is the problem..

Thanks.

boxImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 44, 320, 372)];
        boxImage.image = [UIImage imageNamed:@"chapter1box.png"];
        textScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 175, 320, 755)];
        scrollTextImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 775)];
        scrollTextImg.image = [UIImage imageNamed:@"chapter1narrationtext.png"];
        textScroll.backgroundColor = [UIColor clearColor];
        textScroll.scrollEnabled = YES;
        textScroll.pagingEnabled = YES;
        textScroll.directionalLockEnabled = YES;
        textScroll.autoresizesSubviews = YES;
        textScroll.contentSize = CGSizeMake(320, 775);
        [self.view addSubview:boxImage];
        [boxImage addSubview:textScroll];
        [textScroll addSubview:scrollTextImg];

Upvotes: 0

Views: 565

Answers (3)

tia
tia

Reputation: 9698

UIImageView has userInteractionEnabled property set to NO by default. Adding

boxImage.userInteractionEnabled = YES;

should help.

Upvotes: 4

rockey
rockey

Reputation: 638

in the code i add the scrollview to an image view i added it to the self.view its working now.

cant we add a scroll view to an imageview..?

Upvotes: 0

tadejsv
tadejsv

Reputation: 2092

The scroll view size has to be smaller than the size of it's content for scrolling to work.

Upvotes: 1

Related Questions