我创建了一个带有按钮的UIViewController。该按钮的唯一作用是创建一个用于绘制矩形的窗口。(我从苹果的示例应用程序中提取了"QuartzDemo“中的一些代码。)目标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请帮帮忙--这快把我逼疯了--我已经和同一个基本问题斗争了一个星期了……
发布于 2009-06-13 23:31:15
首先,控制器发布行应该在那里,没有注释。我肯定你只是为了调试而禁用了它。
如果插入行:
NSLog(@"%@", [self navigationController]);在您的按钮操作中,它是记录有效的控制器还是显示为nil?如果它是空的,我猜测这个视图控制器没有被正确地推送到导航控制器本身。
https://stackoverflow.com/questions/991738
复制相似问题