[英]How to Reload UIViewController data of UIVIew
How can I reload data of UIVIewcontroller
from the UIView
.Actually I have a UIVIewController
which has a Custom class class of UIView
.Now In UIViewcontroller
i have a label and i need to print values of label which is been defined in the UIView
. 如何从
UIView
重新加载UIVIewcontroller
数据。实际上我有一个UIVIewController
,它有一个UIView
的Custom类UIViewcontroller
在UIViewcontroller
我有一个标签,我需要打印在UIView
定义的label值。 but viewdidload
of the UIViewController
is been compiled firstly then compiler moves to UIView
.then how can I print or Reload the UIVIewController
但是首先编译了
UIViewController
viewdidload
然后编译器移动到UIView
然后我怎么打印或重新加载UIVIewController
. 。
UILabel Text
I have defined in the View?DidLoad
of UIViewController
and values taken from the UIView
class UILabel Text
我已经在UIViewController
的View?DidLoad
中定义了View?DidLoad
类和从UIView
类获取的值
So How can I reload the UIViewController
. 那么如何重新加载
UIViewController
。
what I am doing is: 我在做的是:
UIVIewController (thirdTab) class UIVIewController (thirdTab)类
-(void)viewDidLoad{
[self reloadInputViews1];
}
-(void)reloadInputViews1{
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
// labelPrint.text=appDelegate.dayPrint;
[self.labelPrint setText:labelPrint.text];
}
UIView class UIView类
- (void)drawRect:(CGRect)rect {
AppDelegate* appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.dayPrint=theDate;
NSLog(@"appde%@",appDelegate.dayPrint);
[appDelegate.thirdTab reloadInputViews1];
}
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 但这不起作用......我无法在label.how中打印值来做到这一点..从UIViews获取值
You can call setNeedsDisplay
on your view to force it to be redrawn. 您可以在视图上调用
setNeedsDisplay
以强制重绘它。 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). 但我不确定这是最好的解决方案,事实上,你可以在你的视图上直接调用
setNeedsDisplay
,你可以在你的控制器上直接调用reloadInputViews1
,它会是相同的(实际上,它会更好)。
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.
我建议您在视图和控制器之间定义委托协议,以使这种关系更加明确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.