我在標籤欄控制器內部有一個視圖控制器。當我在初始化視圖「內部」時,我希望能夠再次按下標籤欄項並重新繪製視圖。在初始化視圖內按下標籤項時重新加載uiview
我tabbarcontroller,在AppDelegate
#AppDelegate.m
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
NSString *titleV = viewController.title;
if (titleV == @"Random") {
DetailViewController *detailViewController = [[DetailViewController alloc] init];
[detailViewController reloadView];
}
}
#ViewController.m
-(void)reloadView{
[self.view setNeedsDisplay];
NSLog(@"view updated");
}
//code
- (void)viewDidLoad
{
[super viewDidLoad];
[self checkContent];
NSLog(@"viewDidLoad");
}
//code
-(void)checkContent{
if (theContent==NULL) {
contentText.numberOfLines=0;
contentText.text = randomContent;
NSLog(@"%@", contentText.text);
} else {
contentText.text = theContent;
}
}
創建從日誌中我可以看到,雖然可視標籤沒有,直到我移動到另外的看法,然後再回到那個contentText.text得到更新。我不知道爲什麼這不起作用。任何關於如何解決這個問題的想法都非常感謝。
如果您需要更多的代碼,我很樂意提供。
乾杯, Dubbelsnurr
一直忙於實現這一點,但肯定的,這解決了這個問題。非常感謝你! – 2012-03-29 13:07:57