Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何清除绘图视图?_Objective C_Ios_Cocoa Touch_Drawing_Draw - Fatal编程技术网

Objective c 如何清除绘图视图?

Objective c 如何清除绘图视图?,objective-c,ios,cocoa-touch,drawing,draw,Objective C,Ios,Cocoa Touch,Drawing,Draw,我目前正在尝试刷新或清除我的UIViewdraw,但很多方法都不起作用。我试过: self.Draw.ClearContextBeforeDrawing [self.Draw设置需要显示] self.Draw.removeFromSuperview 我的代码: -(void)drawPoint:(UITouch *)touch { PointLocation *currentLoc = [[PointLocation alloc] init]; currentLoc.loc

我目前正在尝试刷新或清除我的
UIView
draw,但很多方法都不起作用。我试过:

  • self.Draw.ClearContextBeforeDrawing
  • [self.Draw设置需要显示]
  • self.Draw.removeFromSuperview
  • 我的代码:

    -(void)drawPoint:(UITouch *)touch 
    {
    
        PointLocation *currentLoc = [[PointLocation alloc] init];
    
        currentLoc.location = [touch locationInView:self];
    
        self.previousPoint = self.point;
    
        self.point = currentLoc;
        [self drawToBuffer];
    
        [self setNeedsDisplay];
    }
    

    有没有办法清除我的指纹?或者至少重新加载它?

    这里有一些基本问题

    如何申报抽签?遵循cocoa命名约定。只有类名应该大写。类的实例应以小写字母开头

    我想你想要的是:

    @interface Draw: UIView
    @end
    
    @implementation Draw
    
    - (void) drawRect: (CGRect) r {
      // here you will draw whatever you want in your view.
    }
    
    @end
    
    Draw* draw;
    
    在您的drawPoint方法中:

    [draw setNeedsDisplay];
    
    有关详细信息,请参见视图图形周期:


    要获得额外积分,请将您的观点命名为比画图更具描述性的内容。它是一个视图,一个包含一些内容的窗口。它不是一个动词。

    它的{CGImageRef cgImage=CGBitmapContextCreateImage(offScreenBuffer);UIImage*UIImage=[[UIImage alloc]initWithCGImage:cgImage];CGImageRelease(cgImage);[undoManager beginUndoGrouping];[UIImage drawInRect:self.bounds];}