How to Reload UIViewController data of UIVIew

2019-07-27 06:57发布

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条回答
Emotional °昔
2楼-- · 2019-07-27 07:31

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.

查看更多
登录 后发表回答