One Quickie


Displaying stuff on a monitor hooked up to the phone (UIView->General)
BOOL haveSecondScreen = [UIScreen screens].count > 1;

if (haveSecondScreen) {
    UIScreen *screen = [[UIScreen screens] objectAtIndex: 1];

    // Figure out the largest screen mode we can use.
    CGSize max = CGSizeMake (0.0, 0.0);
    UIScreenMode *maxScreenMode = nil;
    for (UIScreenMode *mode in [screen availableModes]) {
        if (mode.size.width * mode.size.height > max.width * max.height) {
            max = mode.size;
            maxScreenMode = mode;
        }
    }
    screen.currentMode = maxScreenMode;

    UIView *view = [[UIView alloc] initWithFrame: screen.bounds];
    view.backgroundColor = [UIColor greenColor];

    UIWindow *window = [[UIWindow alloc] init];
    window.screen = screen;
    [window addSubview: view];
    window.hidden = NO;

    [view release];
    // Stash |window| into an ivar or something.
}
This doesn't deal with stuff like aspect ratios, etc.



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com