如何删除视图?

时间:2012-07-16 07:07:04

标签: iphone ios ipad

我有一个iphone应用程序,其中我添加了一个视图控制器视图,其中包含一个动画,如flipfrom left。我正在使用navigationbarbutton项目。当点击它时,我正在向我的rootview添加一个视图控制器视图。按钮amd在该动作中我正在删除该视图并添加前一个按钮,但是pbm我需要在该视图中的按钮动作中删除该信息视图。这是我的代码用于翻转。

- (void)backPressed1
{

    InfoViewController *infoviewcontroller = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:nil];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.95];

    //[UIView beginAnimations:nil context:NULL];

    //[UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
    //CGRect frame=CGRectMake(0,0,320,480);
    [rootview removeFromSuperview];
    //[infoviewcontroller.view setFrame:frame];
    //selfhelpscoresAppDelegate *appdelegate=[[UIApplication sharedApplication] delegate];
    [infoviewcontroller viewWillAppear:YES];
    [self.view addSubview:infoviewcontroller.view];
    [UIView commitAnimations];
    UIImage *buttonImage = [UIImage imageNamed:@"information_btn.png"];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:buttonImage forState:UIControlStateNormal];

    button.frame = CGRectMake(0, 0, 42, 32);
    [button addTarget:self action:@selector(backpressed) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    self.navigationItem.rightBarButtonItem = customBarItem;

    //UILabel *label =[[[UILabel alloc]init]autorelease];
    self.navigationItem.title=@"Tutorial";
    //label.text = @"";

    //self.navigationController.title = @"";
    [customBarItem release];

}
-(IBAction)backpressed
{
    InfoViewController *infoviewcontroller = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:nil];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.95];

    //[UIView beginAnimations:nil context:NULL];
    //DailypercentageViewController *pieChart = [[DailypercentageViewController alloc] initWithNibName:@"DailypercentageViewController" bundle:nil];
    //[UIView setAnimationDuration:0.5];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
    //CGRect frame=CGRectMake(0,0,320,370);
    [infoviewcontroller.view removeFromSuperview];
    [self.view addSubview:rootview];
    [UIView commitAnimations];  


    //[rearView setFrame:frame];
        //[pieChart viewDidAppear:YES];

    UIImage *buttonImage1 = [UIImage imageNamed:@"information_btn.png"];
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setImage:buttonImage1 forState:UIControlStateNormal];

    button1.frame = CGRectMake(0, 0, 42, 32);
    [button1 addTarget:self action:@selector(backPressed1) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *customBarItem1 = [[UIBarButtonItem alloc] initWithCustomView:button1];
    self.navigationItem.rightBarButtonItem = customBarItem1;
    [customBarItem1 release];




    //UILabel *label1 =[[[UILabel alloc]init]autorelease];
    self.navigationItem.title=@"";
    //label1.text = @"Home";
    //self.title= @"Home";







}

`我的问题是我如何删除这个infoview并从infoview的按钮操作回到rootview?

0 个答案:

没有答案