2011-08-18 26 views
1

我有這樣的代碼時,我對我的UITexField點擊,我告訴我的UIPopover和我選擇的價值,但我的問題是如何,我可以在其他的廈門國際銀行使用其他textFieldUIPopover,我可以有很多UIViewController到收到所選擇的值` - ?使用UIPopoverController與UItextFiled

(IBAction) btnShowLan:(id) sender { 

    choix=1; 
    if (self.popoverControllerl == nil) { 
     MyPopOverView *movies = [[MyPopOverView alloc] initWithNibName:@"MyPopOverView" 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]; 
} 

////////////////////// 用於recive detailItem

XMLTestAppDelegate *appDelegates = (authe*)[[UIApplication sharedApplication] delegate]; 
     appDelegates.viewController.detailItem =[listOfMovies objectAtIndex:indexPath.row]; 

這個代碼`

+0

山楂我可以使用與其它的XIB的appdelegate? –

回答

0

我認爲你所要求的基本上是「如果我在彈出窗口中有一個帶有值的文本框,並且值發生了變化,我該如何告訴應用程序的其他部分該值已更改。」

雖然可能有很多方法來做到這一點,但這裏有幾種可能性。

1.)創建一個單例類來存儲所有的共享值。當popover改變這個值時,改變這個單例中的值,讓所有其他使用該值的觀察者向單例求值。

2.)使用NSNotification並將chang值存儲在通知「userinfo」中,並將其他類別訂閱到通知中...當彈出窗口發生更改時,彈出窗口發送一個事件。

3.)使用核心數據STOR和改變值在共享數據

+0

waw困難lool –