2010-01-08 58 views
1

我正在意識到什麼新手我仍然與這個問題我有。我正試圖在我正在進行的一個項目中展示一個模式窗口,但它並未出現。然後我的解決方案是創建一個絕對的基本項目,並讓它在那裏工作,所以我會清楚地瞭解我的問題,但我不能甚至這個工作:(presentModalViewController沒有出現在'簡單'應用

我添加一個ViewController到applicationDidFinishLaunching的MainWindow。在這種ViewControllers廈門國際銀行,我有一個按鈕的ViewController具有以下標題:

#import <UIKit/UIKit.h> 
#import "ModalView.h" 

@interface ViewBasedViewController : UIViewController { 
    ModalView *modalView; 
} 

- (IBAction)dooooIt :(id)sender; 

@property (nonatomic, retain, readonly) ModalView *modalView; 

@end 

和方法:

#import "ViewBasedViewController.h" 

@implementation ViewBasedViewController 

@synthesize modalView; 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 

} 

- (void)viewDidUnload { 
} 


- (void)dealloc { 
    [super dealloc]; 
    [modalView release]; 
} 

- (ModalView *)modalView { 
    if (modalView == nil) { 
     modalView = [[ModalView alloc] initWithNibName:@"ModalView" bundle:nil]; 
    } 
    return modalView; 
} 

- (IBAction)dooooIt :(id)sender { 

    [self.navigationController presentModalViewController:modalView animated:YES]; 

} 

@end 

我顯然失去了一些東西很簡單,我相信它在我的耳朵之間這個階段:)

有沒有人想把一個可憐的傢伙擺脫他的痛苦?

非常感謝

克里斯

回答

0

對於那些可能會遇到這個問題,並像我一樣困惑的人,我倒下了解決方案。有兩個問題在dooooIt方法:

- (IBAction)dooooIt :(id)sender { 
    [self presentModalViewController:self.modalView animated:YES]; 

} 

指modalView財產時,我應該已經包括「自我」(否則它是零)和我已經沒有迷上了我不應該提到的navigationController 。

希望這有助於你們任何人(驚人的什麼一杯酒可以做:)

0

您已連接的按鈕IBAction爲?在界面生成器中按住Control鍵並拖動到XIB文件中的「File's Owner」圖標,然後在那裏選擇「dooooIt」方法。重新編譯和你的代碼應該按預期執行。

+0

非常感謝,但是,它是 - !其實我有配音者在presentModalViewController消息打破確保線路正在調用。 – Chris 2010-01-08 17:11:39

+0

dubber =調試器! – Chris 2010-01-08 17:12:17