I have this code when I click on my UITexField
, I show my UIPopover
and I get the value selected,but my problem how I can use other textField
with UIPopover
in other xib ,can i have many UIViewController
to recieve the selected value?`-
(IBAction) btnShowLan:(id) sender {
choix=1;
if (self.popoverControllerl == nil) {
MyPopOverView *movies = [[MyPopOverView alloc] initWithNibName:@"MyPopO开发者_开发问答verView" bundle:[NSBundle mainBundle]];
movies.listOfMovies = [[NSMutableArray alloc] init];
movies.listOfMovies=mutable3;
movies.choix=1;
UIPopoverController *popover =[[UIPopoverController alloc] initWithContentViewController:movies];
popover.delegate = self;
[movies release];
self.popoverControllerl = popover;
[popover release];
}
CGRect popoverRect = [self.view convertRect:[langue frame]
fromView:[langue superview]];
popoverRect.size.width = 20;
popoverRect.size.height =20;
[self.popoverControllerl presentPopoverFromRect:popoverRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
////////////////////// this code used to recive detailItem
XMLTestAppDelegate *appDelegates = (authe*)[[UIApplication sharedApplication] delegate];
appDelegates.viewController.detailItem =[listOfMovies objectAtIndex:indexPath.row];
`
I think what you are asking is basically "if I have a textfield with a value in it in a popover and the value changes, how do I tell other parts of my application that the value has changed."
While there might be a lot of ways of doing it, here are a couple possibilities.
1.) Create a singleton class to store all of your shared value. When the popover changes the value, change that value in the singleton and have all the other observers using that value ask the singleton for its value.
2.) Use an NSNotification and store the chang value in the notifications "userinfo" and subscribe the other classes to the notification...have the popover dispatch an event changed whenenver this changes.
3.) use core data to stor and change the value in shared data
精彩评论