gpt4 book ai didi

iphone - 切换 View Controller ,但旧屏幕仍保留在后面

转载 作者:行者123 更新时间:2023-11-29 04:38:32 25 4
gpt4 key购买 nike

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

我想做的是切换 View 而不需要任何动画。由于某种原因,每当我切换 View 时,旧屏幕都会留下一些东西,例如按钮或文本字段。

如何在每次切换 View 时让这些消失?

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

.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];
}

最佳答案

取消注释

[self presentModalViewController:highScore animated:NO];

并注释掉:

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

线条和一切都会很好。

关于iphone - 切换 View Controller ,但旧屏幕仍保留在后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10730293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com