Saturday, January 11, 2014

UITabBarController how to share data between the two views?

Logically speaking, two general views, A pop-B, B can be accessed using self.presentingViewController attribute A. But on the inside UITabBarController it all becomes ineffective,

A UITabBarController is a view inside. Time is at the bottom of the menu can be switched to the view.
B can not switch the view between the bottom of the menu with.
A pop-up is now a B, then A, B, how to access the property? Seeking answers.
Reply:
Add interfaces to B, then B is initialized to pass the value in A to B
Reply:
cited a floor ran0809 reply:
add interfaces to B, then initialize the value of B in A is passed to B


This problem has found the answer: http://blog.csdn.net/sirodeng/article/details/7914226
Reply:
reference to the second floor u010232872 reply:
Quote: references to a floor ran0809 reply:

Add interfaces to B, B in A after initialization the value passed to the B


This problem has found the answer: http://blog.csdn.net/sirodeng/article/details/7914226



There is another way:

B define a property in the view.

 
@ Property (nonatomic, strong) id delegate;

In A view was time to switch assignments.

 
- (Void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender
{
NSLog (@ "switched");
. ((TaskSelectViewController *) segue.destinationViewController) delegate = self;
}


In this way you can access the B View A view or change the attributes:

 
[((TodayViewController *) self.delegate) currentTaskBtn setTitle: group.name forState:. UIControlStateNormal];


This method comes from: "ios5 Application Development classic" Chapter 12

No comments:

Post a Comment