我有一个UIViewController
然后当我长按self.view
它时会弹出一个弹出窗口(MenuViewController
)。但是当我尝试删除弹出窗口时,removeFromSuperview
它仍然出现
您可以通过此http://www.youtube.com/watch?v=nVVgmeJEnnY查看我的问题的更多详细信息
视图控制器.m
#import "MenuViewController.h"
@interface ViewController () {
MenuViewController *menu;
}
....
- (void)viewDidLoad
{
....
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(albumButtonPressed : ) name:@"albumButtonPressed" object:nil];
....
}
....
-(void)albumButtonPressed : (NSNotification*) notification {
UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init];
photoPicker.delegate = self;
photoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:photoPicker animated:YES];
}
...
-(void)handleLongPress:(UILongPressGestureRecognizer*)recognizer {
menu = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:nil];
if (self.imageView.image != nil) {
menu.imageAdded = YES;
}
[self.view addSubview:menu.view];
}
菜单视图控制器.m
-(IBAction)albumButtonPressed:(id)sender {
[self.view removeFromSuperview];
[[NSNotificationCenter defaultCenter] postNotificationName:@"albumButtonPressed" object:nil];
}