2009-10-20 62 views
2

我有一個應用程序,在UIWindow附加UIViewController附加。 對UIViewController的看法,我添加了一個按鈕和大小100x80的uiview_1。 這uiview_1包含另一個uiview_2爲同樣大小的子視圖,這uiview_2包含UIImageViewUIlable在運行時(包括UIImageViewUIlable啓用userinteractioniphone presentModalViewController

現在觸摸/點擊UIImageView,我想展現出新查看使用presentModalViewController,問題是顯示的視圖和使用導航欄上的後退按鈕我來到前一個/主屏幕。 這裏的問題出現在圖片中,現在我無法觸摸按鈕或UIImageView。 都沒有迴應,但應用程序不會崩潰,也不會被凍結。

這是什麼問題?在此

plz幫助...

----- 編輯

方法一:

SWVController *swvController = [[SWVController alloc] init]; 
UINavigationController *viewNavController = [[UINavigationController alloc] initWithRootViewController:swvController]; 
UIViewController *pushController = [[UIViewController alloc] init]; 
UIWindow *win = [[UIApplication sharedApplication] keyWindow]; 
[win addSubview:pushController.view]; 
[pushController presentModalViewController:viewNavController animated:YES]; 

在swvController我有後退按鈕上調用dismissModelViewController點擊>>結果是主屏幕ctrls沒有響應touch - sandy 3小時前

Second appr oach:

SWVController *swvController = [[SWVController alloc] init]; 
UINavigationController *viewNavController = [[UINavigationController alloc] initWithRootViewController:swvController]; 
UIViewController *pushController = [[UIViewController alloc] init]; 
[self addSubview:pushController.view]; 
[pushController presentModalViewController:viewNavController animated:YES]; 

在swvController我有後退按鈕調用dismissModelViewController上點擊>>結果是swvController對導航欄後退按鈕沒有響應 - 距2小時前

第三屆方法:

SWVController *swvController = [[SWVController alloc] init]; 
UINavigationController *viewNavController = [[UINavigationController alloc] initWithRootViewController:swvController]; 
SampleAppAppDelegate *appdel = [[UIApplication sharedApplication] delegate]; [appdel.viewController presentModalViewController:viewNavController animated:YES]; 

>>結果工作正常,但問題是我不想使用SampleAppAppDelegate,我想給我的小Uiview(100x80)作爲一個ctrl給其他人,我的ctrl將無法獲得AppDelegate的thet應用程序在運行時。 - sandy 3小時前

回答

0

您是如何處理點擊/觸摸UIImageView?的touchesBegan /端?

嘗試把一些日誌(NSLog),並在調試模式下運行你的應用程序(放一些斷點),看看是否達到控制動作方法......

而且,當你做presentModalViewController,你不需要POP導航欄上的後退按鈕...您只需要dismissModelViewController就可以隱藏它。

+0

請結帳我的3種方法... – sandy 2009-10-20 06:33:38

4

呼叫,當你想展示的模態視圖控制器這種方法:

- (IBAction)showInfo {  
    FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil]; 
    controller.delegate = self; 

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
    [self presentModalViewController:controller animated:YES]; 

    [controller release]; 
} 

添加這個方法將你的自我:

- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller { 
    [self dismissModalViewControllerAnimated:YES]; 
} 

使用工具欄或其他按鈕,並把它連接到這個方法在您的模式視圖控制器中:

- (IBAction)done { 
    [self.delegate flipsideViewControllerDidFinish:self]; 
} 

所有代碼都來自Apple。

相關問題