iPhone 使用另一个视图添加视图
我有一个带有个人视图的标签栏应用程序。
所以我有三个视图:
MainWindow.xib(选项卡单击)Favorites.xib(按钮单击)AddFavorites.xib
如何让按钮单击来处理收藏夹?
这是我当前的代码,它总是崩溃。
#import "FavoritesView.h"
#import "FavoritesAddView.h"
@implementation FavoritesView
@synthesize favAddView;
-(IBAction) addButton:(id)sender
{
if (self.favAddView == nil)
{
FavoritesAddView *fView = [[FavoritesAddView alloc]initWithNibName:@"Favorites" bundle:nil];
self.favAddView = fView;
[fView release];
}
[super.view addSubview:favAddView.view];
}
它给了我一个错误: [super.view addSubview:favAddView.view];
错误:程序收到“SIGABRT”
I have a tabbar application with individual views.
So I have three views:
MainWindow.xib (tab click) Favorites.xib (button click) AddFavorites.xib
How would I get the Button click to work on the favorites?
Here is my current code and it always crashes.
#import "FavoritesView.h"
#import "FavoritesAddView.h"
@implementation FavoritesView
@synthesize favAddView;
-(IBAction) addButton:(id)sender
{
if (self.favAddView == nil)
{
FavoritesAddView *fView = [[FavoritesAddView alloc]initWithNibName:@"Favorites" bundle:nil];
self.favAddView = fView;
[fView release];
}
[super.view addSubview:favAddView.view];
}
It gives me an error at the line: [super.view addSubview:favAddView.view];
Error: Program received "SIGABRT"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后一行可能应该是
[self.view.superview addSubview:favAddView.view]
。Probably the last line should be
[self.view.superview addSubview:favAddView.view]
.