iPhone UIScrollView embedded UIView is clipped
Posted
by scc
on Stack Overflow
See other posts from Stack Overflow
or by scc
Published on 2010-03-19T15:30:46Z
Indexed on
2010/03/19
15:31 UTC
Read the original article
Hit count: 340
Hello. I have an iPad UIView subclass (we'll call LargerUIView) with which I do a bunch of drawing via drawRect: once asked. That all appears to be working, and looks the way I like. I'm at the point now of trying to get scrolling working (just in the horizontal to begin), yet when I try to scroll, what shows below is black (ie, appears to have never been drawn). That doesn't surprise me as it's likely been clipped. Looking for suggestions. Here's what I'm doing so far:
MyAppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
CGRect scrollRect = CGRectMake(0, 0, 768, 1024);
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:scrollRect];
LargerUIView *view = (LargerUIView *)[viewController view];
[scrollView addSubview:view];
[scrollView setContentSize:CGSizeMake(768, pageHeight)];
[scrollView setContentMode:UIViewContentModeRedraw];
[scrollView setClipsToBounds:YES];
[window addSubview:scrollView];
[scrollView release];
// Without this next line, the "frontmost" (ie, most recently added subview)
// is the MoxiesAppetizerMenu - which is not equipped to handle scrolling/UIEvents
[window sendSubviewToBack:view];
// Show it all.
[window makeKeyAndVisible];
return YES;
}
Any suggestions? Have tried changing "setClipsToBounds" to NO as well.
© Stack Overflow or respective owner