Basically I want to remove my subview when a button is pressed, here is my code, please tell me what should I add.
I have created a view based application and following are the codes:
//My file name is poo1
//This is poo1ViewController.h file
#import <UIKit/UIKit.h>
@interface poo1ViewController : UIViewController
{
IBOutlet UIButton *fl;
}
@property (nonatomic,retain) UIButton *fl;
-(IBAction) ifl:(id)sender;
@end
This is poo1ViewController.m file
#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];
}
Now similarly I have added a UIViewController Subclass called "flip" with xib. And in flip.h I have added the below code
#import <UIKit/UIKit.h>
@interface flip : UIViewController
{
IBOutlet UIButton *bb;
}
@property (nonatomic,retain)UIButton *bb;
-(IBAction)ss:(id)sender;
@end
And in flip.m
#import "flip.h"
@implementation flip
@synthesize bb;
-(IBAction)ss:(id)sender
{
//What do I need to add here to return to previous view when button is pressed.
}
When this bb button is pressed, it should act as back button, how to implement it.
just add [self removeFromSuperview];
to your method ss:
Note however that this does not dealloc the view from the memory. It's just not showing!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.