我正在尝试从 UIView
中清除 UIBezierPath
。我有一个名为 LinearSig
的类,它具有所有绘图功能。 (来 self 遵循的教程)我在 LinearSig
中有以下方法:
- (void)clearSig {
NSLog(@"clear");
path = nil;
incrementalImage = nil;
path = [UIBezierPath bezierPath];
[self setNeedsDisplay];
}
当我从我的 SigViewController
调用方法时,NSLog
语句被调用并打印到控制台,但路径没有被清除。如果我从 LinearSig
中调用该方法,假设在 touches 方法之后,该方法运行完美。一切都被删除。
我从不同的 View Controller 调用该方法,因为它都在自定义 UIAlertView
中。
这就是我调用方法的方式
- (IBAction)clearSig:(id)sender {
self.ls = [[LinearSig alloc] init];
[self.ls clearSig];
}
ls
是我声明的属性。知道为什么这不起作用吗?
最佳答案
您正在创建 LinearSig
的新实例,然后清除它。您需要指向要清除图形的 LinearSig
实例。
关于ios - 从不同的 UIViewController 调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24458175/