如何重新加载UIVIew的UIViewController数据

实际上我有一个UIVIewController它有一个自定义类的UIViewcontrollerUIViewcontroller我有一个标签,我需要打印UIView定义的标签的值。 但是UIViewController viewdidload是先编译的,然后编译器移动到UIView ,然后我怎么打印或重新载入UIVIewController

UILabel Text我在UIViewControllerView DidLoad中定义了从UIView类中取得的值

那么如何重新加载UIViewController

我正在做的是:

UIVIewController (thirdTab)类

 -(void)viewDidLoad{ [self reloadInputViews1]; } -(void)reloadInputViews1{ appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; // labelPrint.text=appDelegate.dayPrint; [self.labelPrint setText:labelPrint.text]; } 

UIView

 - (void)drawRect:(CGRect)rect { AppDelegate* appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.dayPrint=theDate; NSLog(@"appde%@",appDelegate.dayPrint); [appDelegate.thirdTab reloadInputViews1]; } 

但是这不起作用…我不能够在label.how中打印值..要从UIViews中获取值

您可以在视图上调用setNeedsDisplay来强制重绘。 但是我不确定这是否是最好的解决scheme,事实上,您可以直接在您的控制器上调用reloadInputViews1 ,而不是在您的视图上调用setNeedsDisplay ,它将是相同的(实际上,它会好得多)。

除此之外,我不认为你现在的devise很干净。 我build议你在你的视图和你的控制器之间定义一个委托协议来使这种关系更加明确。