我创建了一个 UIViewController,上面有一个按钮。该按钮的唯一工作是创建一个用于绘制一些矩形的窗口。(我从 Apple 的示例应用程序的“QuartzDemo”中获取了一些代码。)Objective C 真的很适合我……
当我尝试这个时,没有任何反应。
这是按钮的代码:
- (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];
}
老实说,我不确定其他人还需要看什么,但这里有一些其他的东西:
@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
请帮忙——这让我发疯了——我已经与同样的基本问题作斗争了一个星期......