How to Reload UIViewController data of UIVIew

徘徊边缘 提交于 2019-12-11 13:57:48

问题


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. but viewdidload of the UIViewController is been compiled firstly then compiler moves to UIView.then how can I print or Reload the UIVIewController

. UILabel Text I have defined in the ViewDidLoad of UIViewController and values taken from the UIView class

So How can I reload the UIViewController.

what I am doing is:

UIVIewController(thirdTab) class

-(void)viewDidLoad{

 [self reloadInputViews1];

    }



-(void)reloadInputViews1{

appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
//  labelPrint.text=appDelegate.dayPrint;

[self.labelPrint setText:labelPrint.text];

}

UIView class

- (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


回答1:


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.



来源:https://stackoverflow.com/questions/14256931/how-to-reload-uiviewcontroller-data-of-uiview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!