如何重新加载UIVIew的UIViewController数据 [英] How to Reload UIViewController data of UIVIew

查看:58
本文介绍了如何重新加载UIVIew的UIViewController数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 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 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).

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆