Objective c popViewControllerAnimated影响视图是否会出现?

Objective c popViewControllerAnimated影响视图是否会出现?,objective-c,uiviewcontroller,pushviewcontroller,viewwillappear,popviewcontrolleranimated,Objective C,Uiviewcontroller,Pushviewcontroller,Viewwillappear,Popviewcontrolleranimated,我有两节课。比如说A、B班。从类中调用pushviewController,然后将出现B类。问题是,当我从B类调用popviewcontrolleranimated方法时,它会返回到A,但随后会调用这两个类的ViewWillAspect方法。所以任何人都可以告诉我这里发生了什么。我卡住了!。 下面是一节课 @implementation ShakeViewController - (id) init { if (self = [super init]) { movieName = @"

我有两节课。比如说A、B班。从类中调用pushviewController,然后将出现B类。问题是,当我从B类调用popviewcontrolleranimated方法时,它会返回到A,但随后会调用这两个类的ViewWillAspect方法。所以任何人都可以告诉我这里发生了什么。我卡住了!。 下面是一节课

@implementation ShakeViewController

- (id) init {
if (self = [super init]) {
    movieName = @"04";
    self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shake_it.png"]];
    [self.view addSubview:imageView];
    [imageView release];
    nextController = [[OtsugeViewController alloc] init];
}    
return self;
} 

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
const float violence = 1.2;
static BOOL beenhere;
BOOL shake = FALSE;

if (beenhere) return;
beenhere = TRUE;

if (acceleration.x > violence || acceleration.x < (-1* violence))
    shake = TRUE;
if (acceleration.y > violence || acceleration.y < (-1* violence))
    shake = TRUE;
if (acceleration.z > violence || acceleration.z < (-1* violence))
    shake = TRUE;
if (shake && mPlayerPushed) {
    [self playSound:@"suzu"];

    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"noVib"] == NO) {
        AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
    }

    [[UIAccelerometer sharedAccelerometer] setDelegate:nil];
    [self presentModalViewController:mMoviePlayer animated:YES];
    [self play];
    mPlayerPushed = YES;
}

beenhere = false;
}

- (void)toNext {
NSLog(@"ShakeViewController:toNext");
[self.navigationController pushViewController:nextController animated:NO];
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSLog(@"Shake:viewWillAppear");
}

- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:0.5];
}

- (void)dealloc {
[super dealloc];
}

@end

这很正常。每次出现视图时都会调用“视图将出现”。如果只想在视图第一次出现时调用方法,请使用-viewdiload,因为在视图控制器中,堆栈中的每个视图都保存在内存中,但弹出的视图会被释放。

这是正常的。每次出现视图时都会调用“视图将出现”。如果只想在视图第一次出现时调用方法,请使用-viewdiload,因为在视图控制器中,堆栈中的每个视图都保存在内存中,但您弹出的视图将被释放。

您的意思是,在从类B到类a进行弹出操作后,将调用类B ViewWillDisplay?B级也叫B级吗?是的。执行pop操作后,将调用ViewWillDisplay。我没有更改任何关于ViewWillEnglish的内容,因此它是默认值。您的意思是在从B类到A类执行pop操作后调用B类ViewWillEnglish?B级也叫B级吗?是的。执行pop操作后,将调用ViewWillDisplay。我没有更改任何有关ViewWillEnglish的内容,因此它是默认设置。
@implementation OtsugeViewController

- (id) init {
if (self = [super init]) {
    movieName = @"03";
    self.view = [[[OtsugeView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
}
return self;
}

- (void) toNext {
NSLog(@"OtsugeViewController:toNext");
[self.navigationController popViewControllerAnimated:NO];
}

- (void) toToppage
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];        

[self.navigationController popToRootViewControllerAnimated:NO];
}

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"Screen touch Otsuge View");
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                          delegate:self 
                                                        cancelButtonTitle:@"Cancel"  destructiveButtonTitle:nil
                                                otherButtonTitles:@"Retry", @"Main Menu", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;

actionSheet.cancelButtonIndex = 0;
[actionSheet showInView:self.view]; 
[actionSheet release];
}

- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex: (NSInteger)buttonIndex
{
switch (buttonIndex) {
    case 0: // Retry
        [self presentModalViewController:mMoviePlayer animated:YES];
        [self play];
        break;
    case 1: // Main Menu
        [self toToppage];
        break;
    case 2: // Cancel
        break;
    default:
        break;
}
}

- (void) viewWillAppear:(BOOL)animated {
mMoviePlayer.moviePlayer.backgroundView.backgroundColor = [UIColor blackColor];
[self playSound:@"taiko_1"];
NSLog(@"Otsuge:viewWillAppear");
[(OtsugeView *)self.view renewImageView];

[super viewWillAppear:animated];
}

- (void) viewDidAppear:(BOOL)animated{
NSLog(@"Otsuge:viewDidAppear");
[super viewDidAppear:animated];
}

- (void) dealloc {
[super dealloc];
}

@end