当我编译我的代码时,我收到此错误 - “访问属性的未知'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 :(得分:0)
mainViewController
和flipSideViewController
都应将flipDelegate作为实例变量,并确保添加@synthesize
和@property