views:

241

answers:

1

I have a simple application with a "big" text in a "little" UITextView included in an UIImageView. I can't scroll into my text, and i don't understand why ? If there isn't UIImageView, scrolling works.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

UIImage *backImg  = [UIImage imageNamed:@"infoScreen.png"];
UIImageView *background = [[UIImageView alloc] initWithImage:backImg];
UITextView *textview = [[UITextView alloc] initWithFrame:CGRectMake(45, 145, 230, 200)];
textview.text = @"Lorem ipsum dolor [...] deserunt mollit anim id est laborum.";
[background addSubview:textview];
[textview release];
[window addSubview:background];
[background release];
[window makeKeyAndVisible];

return YES;}

Thanks.

+1  A: 

UIImageView by default has userInteractionEnabled set to NO, so scrolling or any interaction wouldn't work by default as a subview of UIImageView.

Set userInteractionEnabled to YES and try again.


The correct way is to make a UIView that contains both the background image and the text view.

UIView* container = ...
...
[container addSubview:background]; [background release];
[container addSubview:textview];   [textview release];
[window addSubview:container];     [container release];
KennyTM
+1 for correct way
Vladimir