我有一个链接到详细子视图的子视图。见下文。这个.h在我目前使用的两个头文件中完全相同,除了@interface _ (一个是JohnAdams,另一个是GeorgeWashington。
@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];
}
在John Adams.m中,它不是加载WebView3和WebView4,而是加载WebView1和WebView2。此外,John Adams.m收到一条警告,即-wikiButtonPressed和bioButtonPressed的方法定义未定义(但不在GeorgeWashington.m上)。我做错了什么?
答案 0 :(得分:0)
您使用的是界面构建器吗? (显然你这样做是因为你宣布IBOutlets)
如果是,请检查JohnAdams.xib文件所有者的类名。