1
我有一個iPad UIView子類(我們將調用LargerUIView),我通過drawRect做了一堆繪圖:一次詢問。這一切似乎都在工作,而且看起來像我喜歡的方式。我現在正試圖進行滾動工作(只是在水平上開始),但當我嘗試滾動時,下面顯示的是黑色(即,似乎從未繪製過)。這並不令我感到意外,因爲它可能已被剪輯。尋找建議。下面是我在做什麼至今:如何防止UIScrollview中嵌入的UIView被剪輯
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 target uiview - which is not equipped to handle scrolling/UIEvents
[window sendSubviewToBack:view];
// Show it all.
[window makeKeyAndVisible];
return YES;
}
有什麼建議?已嘗試將「setClipsToBounds」更改爲NO。