0

我有这种通常有效的方法,但最近它给我带来了麻烦。

我想做的是在没有任何动画的情况下切换视图。出于某种原因,每当我切换视图时,旧屏幕都会留下一些东西,例如按钮或文本字段。

每次切换视图时如何让它们消失?

这是我到目前为止所拥有的

。H

@class HighScoreViewController;

@interface StartUpScreen : UIViewController {
    HighScoreViewController *highScoreViewController;
@property (nonatomic, retain) HighScoreViewController *highScoreViewController;
@end

.m

#import "HighScoreViewController.h"

@implementation StartUpScreen

-(void) viewDidLoad {
    UIButton *highScoreButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    highScoreButton.frame = CGRectMake(219, 0, 99, 55);
    [highScoreButton addTarget:self
                        action:@selector(goToHighScoresViewController)
              forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:highScoreButton];
}

-(void)goToHighScoresViewController {
    HighScoreViewController *highScore = [[HighScoreViewController alloc] initWithNibName:@"HighScoreViewController" bundle:nil];
    self.highScoreViewController = highScore;

    //[self presentModalViewController:highScore animated:YES];

    [self.view insertSubview:highScore.view atIndex:0];
    [highScore release];
}
4

1 回答 1

1

取消注释

[self presentModalViewController:highScore animated:NO];

并注释掉:

[self.view insertSubview:highScore.view atIndex:0];

线条和一切都会很好,花花公子。

于 2012-05-24T04:06:17.653 回答