Ios 从子视图返回到主视图

Ios 从子视图返回到主视图,ios,xcode,ios4,Ios,Xcode,Ios4,基本上我想删除我的子视图时,按下一个按钮,这是我的代码,请告诉我我应该添加什么 我创建了一个基于视图的应用程序,代码如下: //我的文件名是poo1 //这是poo1ViewController.h文件 #import <UIKit/UIKit.h> @interface poo1ViewController : UIViewController { IBOutlet UIButton *fl; } @property (nonatomic,retain) UIButton *f

基本上我想删除我的子视图时,按下一个按钮,这是我的代码,请告诉我我应该添加什么

我创建了一个基于视图的应用程序,代码如下:

//我的文件名是poo1

//这是poo1ViewController.h文件

#import <UIKit/UIKit.h>
@interface poo1ViewController : UIViewController 
{
 IBOutlet UIButton *fl;
}
@property (nonatomic,retain) UIButton *fl;
-(IBAction) ifl:(id)sender;    
@end
    #import "poo1ViewController.h"
    @implementation poo1ViewController
    @synthesize fl;
    -(IBAction) ifl:(id) sender {
    UIViewController* flipViewController = [[UIViewController alloc] initWithNibName:@"flip" bundle:[NSBundle mainBundle]];
    [self.view addSubview:flipViewController.view];
    }
#import <UIKit/UIKit.h>
@interface flip : UIViewController 
{
    IBOutlet UIButton *bb;
}
@property (nonatomic,retain)UIButton *bb;
-(IBAction)ss:(id)sender;
@end
现在,我同样添加了一个名为“flip”的UIViewController子类和xib并在flip.h中添加了以下代码

#import <UIKit/UIKit.h>
@interface poo1ViewController : UIViewController 
{
 IBOutlet UIButton *fl;
}
@property (nonatomic,retain) UIButton *fl;
-(IBAction) ifl:(id)sender;    
@end
    #import "poo1ViewController.h"
    @implementation poo1ViewController
    @synthesize fl;
    -(IBAction) ifl:(id) sender {
    UIViewController* flipViewController = [[UIViewController alloc] initWithNibName:@"flip" bundle:[NSBundle mainBundle]];
    [self.view addSubview:flipViewController.view];
    }
#import <UIKit/UIKit.h>
@interface flip : UIViewController 
{
    IBOutlet UIButton *bb;
}
@property (nonatomic,retain)UIButton *bb;
-(IBAction)ss:(id)sender;
@end

当按下此bb按钮时,它应该充当后退按钮,如何实现它。

只需添加
[self removeFromSuperview]到您的方法
ss:

但是请注意,这不会从内存中解除锁定视图。它只是不显示

只需添加
[self removeFromSuperview]到您的方法
ss:

但是请注意,这不会从内存中解除锁定视图。它只是不显示

它显示警告并说“翻转可能不响应从Superview移除OK。。。尝试将flip的父类从controller更改为view@interface flip:UIViewIt已经是UIView,我已将项目上载到此处:。请你检查一下,指出我的错误,然后编辑程序并重新上传。如果您这样做,我们将不胜感激。好的。解决方案是写入[self.view removeFromSuperview];在方法ss:(id)发送方中。我认为不应该为pp类扩展UIViewController。您可以只使用UIView。看起来你是从iOS开始的,所以这对你来说是一个很好的练习。试着用UIView做同样的事情……你也可以,通过这样做[self.view removeFromSuperview];它会从内存中释放视图吗?它会显示警告并显示“翻转可能不响应从Superview移除OK。。。尝试将flip的父类从controller更改为view@interface flip:UIViewIt已经是UIView,我已将项目上载到此处:。请你检查一下,指出我的错误,然后编辑程序并重新上传。如果您这样做,我们将不胜感激。好的。解决方案是写入[self.view removeFromSuperview];在方法ss:(id)发送方中。我认为不应该为pp类扩展UIViewController。您可以只使用UIView。看起来你是从iOS开始的,所以这对你来说是一个很好的练习。试着用UIView做同样的事情……你也可以,通过这样做[self.view removeFromSuperview];它会从内存中释放视图吗