如何在iOS中从另一个ViewController调用UIView方法

问题描述 投票:0回答:1

我已经实现了

的手绘草图教程
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk_freehand-drawing/. 

我需要在视图控制器中调用其

- (void)drawBitmap;
- (void)drawBitmapGreen;
方法来更改按钮操作的颜色。我做了类似下面的事情。

#import <UIKit/UIKit.h>
#import "checklistController.h"
@interface SmoothedBIView : UIView

@property(nonatomic,assign) checklistController *trnsferColor;
- (void)drawBitmapGreen;
@end

@implementation SmoothedBIView

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self drawBitmapred];
    [self drawBitmapGreen];
    [self setNeedsDisplay];
    [path removeAllPoints];
    ctr = 0;
}
- (void)drawBitmapGreen
{
    UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 0.0);
    if (!incrementalImage) // first time; paint background white
    {
        UIBezierPath *rectpath = [UIBezierPath bezierPathWithRect:self.bounds];
        [[UIColor clearColor] setFill];
        [rectpath fill];
    }
    [incrementalImage drawAtPoint:CGPointZero];
    [[UIColor greenColor] setStroke];
    [path stroke];
    incrementalImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    //SmoothedBIView.trnsferColor = self;
}

...

 @interface checklistController :   UIViewController

 @property(nonatomic,strong) IBOutlet UIView *vPaintPreview; //SmoothedBIview outlet for hidden and unhidden property.
 @property(nonatomic,assign) SmoothedBIview *SBIView;
-(IBAction)editvImage;
-(IBAction)RedSketch;
-(IBAction)GreenSketch;

更新代码

@implementation file

-(IBAction)GreenSketch
{
    SmoothedBIView *SBIview = [[SmoothedBIView alloc] init];
    [SBIview drawBitmapGreen];
}

我在这里做错了什么?

iphone ios objective-c uiview uiviewcontroller
1个回答
0
投票

您是否尝试过以下操作:

-(IBAction)GreenSketch
{
    

 
 }
© www.soinside.com 2019 - 2024. All rights reserved.