在我使用第二个XIB之后,我正在尝试将A改回主xib。这是我正在使用的当前代码:
NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"Results1" owner:self options:nil];
UIView *aView = [nibObjs objectAtIndex:0];
self.view = aView;我在第二个xib上有一个按钮,它返回到原始的xib。当我按下按钮时,应用程序就崩溃了。我不确定为什么,因为它没有显示错误-它只是崩溃了。以下是第二个xib或"Results1“xib文件上按钮上的代码:
-(IBAction)Button100:(id)sender
{
NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"main" owner:self options:nil];
UIView *aView = [nibObjs objectAtIndex:0];
self.view = aView;
}不确定我做错了什么。
发布于 2012-08-15 00:07:20
问题是我需要关闭自动引用计数。
发布于 2012-08-10 08:46:03
添加为子视图,这样你就可以“弹出”Results1视图了:
// in your .h
@property (strong) UIView *aView;
// replace your provided code with this
NSArray *nibObjs = [[NSBundle mainBundle] loadNibNamed:@"Results1" owner:self options:nil];
self.aView = [nibObjs objectAtIndex:0];
[self.view addSubview:self.aView];
- (IBAction)Button100:(id)sender
{
[self.aView removeFromSuperview];
self.aView = nil;
}这只是一个建议--如果你想让它们“交换”,可以考虑在UIView中使用类方法transitionFromView:toView:duration:options:completion:。
https://stackoverflow.com/questions/11893963
复制相似问题