1

我有一个 iPad UIView 子类(我们将调用 LargerUIView),我通过 drawRect 进行一堆绘图:一旦被问到。这一切似乎都在起作用,并且看起来像我喜欢的那样。我现在正试图让滚动工作(只是在水平开始),但是当我尝试滚动时,下面显示的是黑色(即,似乎从未绘制过)。这并不让我感到惊讶,因为它可能被剪掉了。寻找建议。到目前为止,这是我正在做的事情:

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。

4

1 回答 1

0

叹。多么愚蠢。LargerUIView 在 InterfaceBuilder 中设置得更小。忘记添加这样的行:

[view setBounds:CGRectMake(0, 0, 768, pageHeight)];

哎呀。

于 2010-03-19T19:17:58.367 回答