如何重新加载UIVIew的UIViewController数据 [英] How to Reload UIViewController data of UIVIew
问题描述
如何从 UIView
重新加载 UIVIewcontroller
的数据.实际上,我有一个 UIVIewController
,该类的自定义类为UIView
.现在在 UIViewcontroller
中,我有一个标签,我需要打印在 UIView
中定义的label的值.但是先编译了 UIViewController
的 viewdidload
,然后编译器移至 UIView
.然后如何打印或重新加载 UIVIewController 代码>
.我在 UIViewController
的 View?DidLoad
中定义了 UILabel文本
,并从 UIView
类
所以我该如何重新加载 UIViewController
.
我正在做的是:
UIVIewController (thirdTab)类
-(void)viewDidLoad {[self reloadInputViews1];}-(无效)reloadInputViews1 {appDelegate =(AppDelegate *)[[UIApplication sharedApplication]委托];//labelPrint.text = appDelegate.dayPrint;[self.labelPrint setText:labelPrint.text];}
UIView 类
-(void)drawRect:(CGRect)rect {AppDelegate * appDelegate =(AppDelegate *)[[UIApplication sharedApplication]委托];appDelegate.dayPrint = theDate;NSLog(@"appde%@",appDelegate.dayPrint);[appDelegate.thirdTab reloadInputViews1];}
但是这不起作用...我无法在标签中打印值.如何执行..以从UIViews中获取值
您可以调用 But this does not work ...I am not able to print values in the label.how to do that..to get values from the UIViews You can call Apart from this, I don´t think that your current design is very clean. I would suggest you to define a delegate protocol between your view and your controller to make that kind of relationship more explicit. 这篇关于如何重新加载UIVIew的UIViewController数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!setNeedsDisplay
on your view to force it to be redrawn. But I am not sure that this is the best solution, in fact, instead of calling setNeedsDisplay
on your view, you could call directly reloadInputViews1
on your controller and it would be the same (actually, it would be much better).