我为我的UIView(draw2D)和ViewController(ViewControllerImage)创建了一个类文件
当视图加载时,viewControllerImage接收推送变量。这有效,我现在需要将变量分配到draw2D。
draw2D.h
@property (nonatomic, assign) double thicknessValue2;
如何在viewDidLoad中的ViewController中访问它以在draw2D中设置变量?
答案 0 :(得分:0)
我假设您的draw2D
视图是ViewControllerImage
视图的属性/子视图?
此属性的setter可以使用以下两种方式之一:
myDraw2D.thicknessValue2 = whatever;
或
[myDraw2D setThicknessValue2:whatever];
答案 1 :(得分:0)
在draw2D
(UIViewController)中实例化viewControllerImage
(UIView)并访问它的属性。
如,
UIView *someView= (UIView *)[[[NSBundle mainBundle] loadNibNamed:@"nameOfXIB" owner:nil options:nil] objectAtIndex:0];
[self.view addSubView:someView];
someView.thicknessValue2 = YourPushedValue;
不要忘记在@synthesize
文件中thicknessValue2
.m
。
希望它有所帮助!