i've created a custom view controller and a custom view programmatically and while everything compiles fine, i only see a white screen in the iphone simulator *except* when i press the home button, where i can THEN see the drawing i've done to the view as it shrinks into obscurity. any idea why i'm not seeing my view while the app is actively running?
here's the relevant code:
app delegate's didFinishLaunchingWithOptions
view controller's loadView:
custom view's drawRect:
again, i do see the rectangle drawn above, but only AFTER the home button has been hit to close the app.
ps. this really doesn't need justification, but this IB avoidance is a one-off thing, so just bear with me and thanks in advance for your help
here's the relevant code:
app delegate's didFinishLaunchingWithOptions
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
CGRect rect = CGRectMake(0.0, 0.0, 320, 480);
window = [[UIWindow alloc] initWithFrame:rect];
viewController = [[ViewController alloc] init];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
view controller's loadView:
Code:
- (void)loadView {
CGRect cgRct = CGRectMake(0.0, 0.0, 320, 480);
myView = [[CustomView alloc] initWithFrame:cgRct];
myView.autoresizesSubviews = YES;
self.view = myView;
}
custom view's drawRect:
Code:
- (void)drawRect:(CGRect)rect {
CGContextRef theContext = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(theContext, .5, .5, .5, 1);
CGContextFillRect(theContext, rect);
NSLog(@"drawRect"); //yes, it get's called
}
again, i do see the rectangle drawn above, but only AFTER the home button has been hit to close the app.
ps. this really doesn't need justification, but this IB avoidance is a one-off thing, so just bear with me and thanks in advance for your help