2012-10-29 40 views
0

我打開一個視圖控制器(帶導航欄和關閉視圖控制器欄按鈕項)。這是視圖控制器是用於向用戶顯示信息時,他點擊了「幫助」按鈕。導航是這樣的:ViewController1 - >「幫助」按鈕 - > Viewcontroller2。 Viewcontroller2有一個關閉按鈕,關閉這個ViewController。我有一個IBAction關閉按鈕的文件所有者的關閉按鈕,但是當我點擊'關閉'按鈕時,中斷點沒有被擊中。該代碼是:按鈕關閉UIViewController中單擊

DetailViewController.m(viewcontroller1):

-(void) showHelp:(id)sender 
{ 
    HelpViewController *helpWindow = [[HelpViewController alloc]initWithNibName:@"HelpViewController" bundle:[NSBundle mainBundle]]; 
    helpWindow.modalPresentationStyle = UIModalPresentationFormSheet; 
    [self presentModalViewController:helpWindow animated:YES]; 
} 

HelpViewController.m(viewcontroller2):

#import "HelpViewController.h" 

@interface HelpViewController() 

@end 

@implementation HelpViewController 

@synthesize scrollView; 


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

- (IBAction)closeAction:(id)sender { 
    [self dismissModalViewControllerAnimated:YES]; 

} 

@end 

我試圖把一個斷點 「closeAction」 但它不是擊中。我是iOS開發新手。我錯過了一些非常明顯的東西。任何幫助表示讚賞!

回答

1

點擊您的Close按鈕,然後選擇右側工具中的connection inspector選項卡。在touchUpInside模式下檢查您的按鈕是否與closeAction:連接。

如果沒有,則將您的UIButton插座連接到此方法-(IBAction)closeAction:(id)sender;然後嘗試。

UPDATE:如果您的按鈕是UIBarButtonItem,那麼將會有一個選項爲"New referencing outlet"。從中拖拽並連接你的方法。

+0

「關閉」按鈕「欄按鈕項目」導航Bar.When裏面我點擊連接督察「關閉」按鈕,沒有「touchUpInside」的選項。我有一個IBOutlet在.h和IBAction也在同一個.h文件中。我如何將它們連接到對方? – user1550951

+0

現在檢查我的答案... –

+0

我很抱歉聽起來像一個nOOb!當我點擊「新引用插座」並拖動到「關閉」按鈕,方法名稱doesnt顯示。我應該這樣做的不同? – user1550951