[英]calling a parent UIViewController method from a child UIViewController
[英]Calling method from different UIViewController
我正在嘗試從UIView
清除UIBezierPath
。 我有一個名為LinearSig
的類,它具有所有繪圖功能。 (從我遵循的教程中)我在LinearSig
具有以下方法:
- (void)clearSig {
NSLog(@"clear");
path = nil;
incrementalImage = nil;
path = [UIBezierPath bezierPath];
[self setNeedsDisplay];
}
當我從SigViewController
調用該方法時,將調用NSLog
語句並將其打印到控制台,但不會清除路徑。 如果我從LinearSig
內部調用該方法,可以在touches方法之后說,該方法可以正常工作。 一切都被刪除。
我從另一個視圖控制器調用該方法,因為它都在自定義UIAlertView
。
這就是我調用方法的方式
- (IBAction)clearSig:(id)sender {
self.ls = [[LinearSig alloc] init];
[self.ls clearSig];
}
ls
是我已聲明的屬性。 知道為什么這不起作用嗎?
您正在創建一個LinearSig
的新實例,然后清除它。 您需要指向您要清除圖形的LinearSig
實例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.