【问题标题】:accessing unknown 'flipDelegate' component of a property访问属性的未知“flipDelegate”组件
【发布时间】:2011-07-30 18:53:27
【问题描述】:

您好,当我编译我的代码时,我收到此错误-“访问属性的未知 '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

【问题讨论】:

    标签: ios4 iphone-sdk-3.0 cocos2d-iphone iphone


    【解决方案1】:

    mainViewControllerflipSideViewController 都应该将 flipDelegate 作为实例变量,并确保添加 @synthesize@property

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-16
      • 2020-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多