2011-08-28 85 views
0

我有一個鏈接到詳細子視圖的子視圖。見下文。這.H恰恰是在我目前使用兩個頭文件相同,除了@interface _(上一個和喬治·華盛頓約翰·亞當斯在其他。獲取錯誤,該方法未定義

@interface JohnAdams : UIViewController { 

NSString *selectedCountry; 
IBOutlet UIButton *bio; 
IBOutlet UIButton *wiki; 
} 
@property (nonatomic, retain) NSString *selectedCountry; 
@property (nonatomic, retain) UIButton *wiki; 
@property (nonatomic, retain) UIButton *bio; 

-(IBAction)wikiButtonPressed:(id)sender; 
-(IBAction)bioButtonPressed:(id)sender; 
@end 

但是,看一看兩個.M的

//George Washington.m 
-(IBAction)wikibuttonPressed:(id)sender { 
WebView1 *detailvc = [[WebView1 alloc] initWithNibName:@"WebView1" bundle:nil]; 
[detailvc setTitle:@"Wikipedia"]; 
[self.navigationController pushViewController:detailvc animated:YES]; 
[detailvc release]; 

} 

-(IBAction)biobuttonPressed:(id)sender { 
WebView2 *detailvc2 = [[WebView2 alloc] initWithNibName:@"WebView2" bundle:nil]; 
[detailvc2 setTitle:@"The White House"]; 
[self.navigationController pushViewController:detailvc2 animated:YES]; 
[detailvc2 release]; 
} 

//JohnAdams.m 
-(IBAction)biobuttonPressed:(id)sender { 
WebView4 *detailvc4 = [[WebView4 alloc] initWithNibName:@"WebView4" bundle:nil]; 
[detailvc4 setTitle:@"The White House"]; 
[self.navigationController pushViewController:detailvc4 animated:YES]; 
[detailvc4 release]; 
} 


-(IBAction)wikibuttonPressed:(id)sender { 
WebView3 *detailvc3 = [[WebView3 alloc] initWithNibName:@"WebView3" bundle:nil]; 
[detailvc3 setTitle:@"Wikipedia"]; 
[self.navigationController pushViewController:detailvc3 animated:YES]; 
[detailvc3 release]; 

} 

在約翰Adams.m,而不是裝載WebView3和WebView4,它加載WebView1和WebView2。此外,約翰Adams.m收到一個警告,方法定義爲兩個-wikiButtonPressed和bioButtonPressed未定義(但不在GeorgeWashington.m上)我做錯了?

+0

因此,當JohnAdams生物按鈕被按下時,執行不會輸入JohnAdams.m中的代碼?如果是這種情況,則xib可能與錯誤的控制器相關聯。 –

回答

0

您使用的是界面生成器嗎? (顯然,你這樣做,因爲您聲明IBOutlets)

如果是這樣,然後檢查JohnAdams.xib的文件所有者的類名。