[英]UIImage from UIView to UIViewController
我正在UIView的drawRect函數中以編程方式創建UIImage。 有沒有辦法讓負責此UIView的UIViewController訪問該圖像(或其副本)進行操作?
感謝任何指針,並在此先感謝。
如果您在drawrect中以編程方式創建的UIImage作為屬性存儲在UIView子類中,則UIViewController可以訪問該圖像。
顯然,如果您正在使用Interface Builder,則需要將UIView子類連接到UIViewController類上的IBOutlet來訪問該屬性,但是我確定您已經在這樣做了。
e.g. in the drawrect function
self.storedImage = [[UIImage alloc] init... ];
in the header for the UIView subclass
UIImage* storedImage;
@property (nonatomic, retain) UIImage* storedImage;
非原子保留屬性可確保您不會在每次調用draw rect函數時泄漏UIImage。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.