2011-04-06 127 views
0

嗨的未知「flipDelegate」成分當我編譯我的代碼,我得到這個錯誤 - 「訪問屬性的未知‘flipDelegate’組件」訪問屬性

這是從那裏我得到的錯誤代碼 -

// 
// RootViewController.m 
// Dolphia 
// 
// Created by Dolphia Nandi on 4/3/11. 
// Copyright 2011 State University of New York at Buffalo. All rights reserved. 
// 


#import "RootViewController.h" 
#import "MainViewController.h" 
#import "FlipSideViewController.h" 

@implementation RootViewController 

@synthesize mainViewController; 
@synthesize flipSideViewController; 

- (void)loadMainViewController { 
    MainViewController *viewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil]; 
    self.mainViewController = viewController; 
    self.mainViewController.flipDelegate = self; 
    [viewController release]; 
} 

- (void)loadFlipSideViewController { 
    FlipSideViewController *viewController = [[FlipSideViewController alloc] initWithNibName:@"FlipSideViewController" bundle:nil]; 
    self.flipSideViewController = viewController; 
    self.flipSideViewController.flipDelegate = self; 
    [viewController release]; 
} 

- (void)viewDidLoad { 
    [self loadMainViewController]; // Don't load the flipside view unless/until necessary 
    [self.view addSubview:mainViewController.view]; 
} 

// This method is called when either of the subviews send a delegate message to us. 
// It flips the displayed view from the whoever sent the message to the other. 
- (void)toggleView:(id)sender { 
    if (flipSideViewController == nil) { 
     [self loadFlipSideViewController]; 
    } 

    UIView *mainWindow = mainViewController.view; 
    UIView *flipSideView = flipSideViewController.view; 
    /*[UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1]; 
    if(flipeffect >= 0 && flipeffect < 2) { 
     flipeffect++; 
     [UIView setAnimationTransition:((voiceViewController == sender) ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES]; 
    } else if (flipeffect >= 2 && flipeffect < 4) { 
     flipeffect++; 
     [UIView setAnimationTransition:((voiceViewController == sender) ? UIViewAnimationTransitionCurlUp : UIViewAnimationTransitionCurlDown) forView:self.view cache:YES]; 
    } else if (flipeffect >= 4 && flipeffect < 6) { 
     flipeffect++; 
     [UIView setAnimationTransition:((voiceViewController == sender) ? UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight) forView:self.view cache:YES]; 
    } else { 
     flipeffect++; 
     if(flipeffect > 7) 
      flipeffect = 0; 
     [UIView setAnimationTransition:((voiceViewController == sender) ? UIViewAnimationTransitionCurlDown : UIViewAnimationTransitionCurlUp) forView:self.view cache:YES]; 
    }*/ 

    if (mainViewController == sender) { 
     [flipSideViewController viewWillAppear:YES]; 
     [mainViewController viewWillDisappear:YES]; 
     [mainWindow removeFromSuperview]; 
     [self.view addSubview:flipSideView]; 
     [mainViewController viewDidDisappear:YES]; 
     [flipSideViewController viewDidAppear:YES]; 
    } else { 
     [mainViewController viewWillAppear:YES]; 
     [flipSideViewController viewWillDisappear:YES]; 
     [flipSideView removeFromSuperview]; 
     [self.view addSubview:mainWindow]; 
     [flipSideViewController viewDidDisappear:YES]; 
     [mainViewController viewDidAppear:YES]; 
    } 
    //[UIView commitAnimations]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview 
    // Release anything that's not essential, such as cached data 
} 

- (void)dealloc { 
    [mainViewController release]; 
    [flipSideViewController release]; 
    [super dealloc]; 
} 

@end 

回答

0

兩個mainViewControllerflipSideViewController應該有flipDelegate爲實例變量,並確保您添加@synthesize@property