首先要定义
@protocol PainterSetupViewDelegate;
这是定义接口
@protocol PainterSetupViewDelegate<NSObject>
- (void)painterSetupViewController:(PainterSetupViewController *)
controller setColor:(UIColor *)color;
- (void)painterSetupViewController:(PainterSetupViewController *)
controller setWidth:(float)width;
@end
使用他的时候
.h里定义他
@interface ViewController : UIViewController<PainterSetupViewDelegate>
{
}
@end
.m里就得实例化他了
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(IBAction)PenClick // Pen Type
{
[(MainPainterView *)self.view setpCurType:PEN];
}
-(IBAction)LineClick // Line Type
{
[(MainPainterView *)self.view setpCurType:LINE];
}
-(IBAction)CircleClick // Circle Type
{
[(MainPainterView *)self.view setpCurType:CIRCLE];
}
-(IBAction)EraseClick // Erase Type
{
[(MainPainterView *)self.view setpCurType:ERASE];
}
-(IBAction)RectangleClick // Taegeuk Type
{
[(MainPainterView *)self.view setpCurType:RECTANGLE];
}
-(IBAction)SetupClick
{
if (pPainterSetupViewController == nil) {
PainterSetupViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PainterSetupViewController"];
viewController.delegate = self;
pPainterSetupViewController = viewController;
}
[self presentViewController:pPainterSetupViewController animated:YES completion:nil];
}
- (void)painterSetupViewController:(PainterSetupViewController *) controller setColor:(UIColor *)color
{
[(MainPainterView *) self.view setpCurColor:color];
}
- (void)painterSetupViewController:(PainterSetupViewController *) controller setWidth:(float)width
{
[(MainPainterView *) self.view setpCurWidth:width];
}
@end
没有评论:
发表评论