iOS 代码加载了错误的 nib 文件?
我有一个应用程序,它是一个列表。当您点击列表项时,它会加载专门针对该单元格的单独笔尖。第二个笔尖有两个按钮,每个按钮都与另一个笔尖文件关联。在我的 Cell1.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];
}
但是,当我尝试在 Cell2.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];
}
它加载与我的第一个代码片段(WebView1 和 WebView2,而不是 WebView3 和 WebView4)关联的 nib 文件。此外,我在 Cell2.m 上收到一条警告,指出 bioButtonPressed 和 wikiButtonPressed 未定义。我做错了什么?
I have an app that is a list. When you tap on a list item, it loads a separate nib specifically for that cell. This second nib has two buttons, each associated with yet another nib file. The first implementation of this code in my Cell1.m file works fine to open the nib on response to the button pressed inside the detail views with no errors / warmings:
-(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];
}
However, when I try to implement this code on Cell2.m, rather than loading this:
-(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];
}
it loads the nib files associated in my first snippet of code (WebView1 & WebView2, rather than WebView3 and WebView4). Additionally, I get an warning on Cell2.m saying bioButtonPressed and wikiButtonPressed were not defined. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查这些方法的定义是否与 Cell2.h 中的匹配,以及出口是否设置正确。
Check that the definition of those methods matches in Cell2.h, and that the outlets are correctly set.