views:

341

answers:

1

I create a UIViewController with a button on it. The button's only job is to create a window for drawing some rectangles. (I've taken some code from "QuartzDemo" from Apple's example applications.) Objective C is really giving me fits...

When I try this, nothing happens.

Here's the code for the button:

- (IBAction)startButtonAct:(id)sender
{
    QuartzViewController *controller;

    NSLog(@"1");
    controller = [[QuartzViewController alloc] initWithTitle:@"Dotsie"];
    controller.quartzViewDelegate = [[[RectDrawing alloc] init] autorelease];
    [[self navigationController] pushViewController:controller animated:YES];
    // [controller release];

}

I'm honestly not sure what else anyone needs to see, but here's some of the other stuff:

@interface QuartzViewController : UIViewController
{
    QuartzView *quartzView;
    UIBarStyle barStyle;
    UIStatusBarStyle statusStyle;

}


@protocol QuartzViewDelegate;

@interface QuartzView : UIView {

id<QuartzViewDelegate> delegate;

}

@property(assign) id<QuartzViewDelegate> delegate;

@end

@protocol QuartzViewDelegate<NSObject>

@required

// Draw contents into the given view, using the given context and bounds.
-(void)drawView:(QuartzView*)view inContext:(CGContextRef)context bounds:(CGRect)bounds;

@end

Please help -- this is driving me crazy -- I've been fighting with the same basic problem now for a week...

+1  A: 

First, the [controller release] line should be there, uncommented. I'm sure you just disabled it for debugging.

If you insert the line:

NSLog(@"%@", [self navigationController]);

In your button action, does it log a valid controller or does it say nil? If it's nil, my guess is that this view controller wasn't properly pushed onto a navigation controller itself.

NilObject