私は通常はうまくいくこの方法を持っていますが、最近それは私に問題を与えています。
私がやろうとしているのは、アニメーションなしでビューをスイッチに切り替えることです。何らかの理由で、ビューを切り替えるたびに、ボタンやテキストフィールドなど、古い画面にいくつかのものが残ります。
ビューを切り替えるたびにそれらを削除するにはどうすればよいですか?
これが私がこれまでに持っているものです
.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];
}