OGeek|极客世界-中国程序员成长平台

标题: ios - 将数据从 Viewcontroller 传输到 UIview [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 09:29
标题: ios - 将数据从 Viewcontroller 传输到 UIview

我正在尝试使用

在 UIView 中绘制图表
-(void)drawRectCGRect)rect
{
    [super drawRect:rect];
    CGContextMoveToPoint(context, 0f, 0f);
    CGContextAddLineToPoint(context, Value1, 0);
    CGContextStrokePath(context);
}

如果我在 UIView.m 中定义 Value1 ,它可以工作,但是: Value1 应该从另一个 ViewController 传输,我在其中将 Value 输入到 Textfield。

如何将值 1 转移到我的 UIView 中?

(我可以将 Value 转移到另一个 ViewController,但在 ViewController 中我的 drawRect 方法不起作用)



Best Answer-推荐答案


YourViewClass.h

{
@public
    CGFloat Value1;
}

View Controller

myView->Value1 = someValue;
[myView setNeedsDisplay];

关于ios - 将数据从 Viewcontroller 传输到 UIview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31794089/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4