2010-06-15 76 views
4

我有這個錯誤,當我建立我的應用程序的iPhone: 請求成員視圖中的東西不是結構或聯合[CommuneSlider.view removeFromSuperview];請求成員視圖中的東西不是結構或工會

代碼: - (無效)CommuneSelected {

CommuneDetailsViewController *com = [[CommuneDetailsViewController alloc] initWithNibName:@"CommuneDetailsViewController" bundle:nil]; 

UINavigationController *navig = [[UINavigationController alloc] 
           initWithRootViewController:com]; 
[self setCommuneDetails:(CommuneDetailsViewController *) navig]; 
[navig setNavigationBarHidden:YES]; 
[com release]; 
[navig release]; 


[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDuration:.8]; 
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES]; 

[CommuneSlider.view removeFromSuperview]; 
[self.window addSubview:[CommuneDetails view]]; 

[UIView commitAnimations]; 

}

需要幫助的

回答

0

如果這是C++,我會說:「有一個指針指向一個類,您嘗試說pClass.foo而不是pClass->foo「,或者您嘗試訪問的」view「變量的類型由於某種原因而未知。也許這可以幫助Objective-C。

+0

事實上,它是在客觀C和communeSlider的是,我在myAppDelegate @synthesize CommuneSlider定義它的屬性; @synthesize CommuneDetails; – james 2010-06-15 13:32:33

+0

那麼,它是一個指針還是一個結構/類?你看,我只在C++上下文中看到過這些錯誤,而Objective-C幾乎沒有任何經驗 – iksemyonov 2010-06-15 13:36:29

1

確定這是AzurGuideAppDelegate.h:

@class CommuneSliderController, AccueilViewController,CommuneDetailsViewController; 

@interface AzurGuideAppDelegate : NSObject <UIApplicationDelegate> { 
    UIWindow *window; 
    AccueilViewController *AccueilController; 
    CommuneSliderController *CommuneSlider; 
    CommuneDetailsViewController *CommuneDetails; 
    UINavigationController *navigationControl; 

} 

@property (nonatomic, retain) IBOutlet UIWindow *window; 
@property (nonatomic, retain) IBOutlet AccueilViewController *AccueilController; 
@property (nonatomic, retain) IBOutlet CommuneSliderController *CommuneSlider; 
@property (nonatomic, retain) IBOutlet CommuneDetailsViewController *CommuneDetails; 


- (void) goBack; 
- (void) goFront; 
- (void) CommuneSelected; 

@end 

這裏的AzurGuideAppDelegate.m在那裏我定義我的方法:

#import "AzurGuideAppDelegate.h" 
#import "AccueilViewController.h" 


@implementation AzurGuideAppDelegate 

@synthesize window; 
@synthesize AccueilController; 
@synthesize CommuneSlider; 
@synthesize CommuneDetails; 


- (void)applicationDidFinishLaunching:(UIApplication *)application {  

    // Override point for customization after application launch 

    [window addSubview:AccueilController.view]; 
    [window makeKeyAndVisible]; 
} 

- (void) CommuneSelected { 

    CommuneDetailsViewController *com = [[CommuneDetailsViewController alloc] initWithNibName:@"CommuneDetailsViewController" bundle:nil]; 

    UINavigationController *navig = [[UINavigationController alloc] 
            initWithRootViewController:com]; 
    [self setCommuneDetails:(CommuneDetailsViewController *) navig]; 
    [navig setNavigationBarHidden:YES]; 
    [com release]; 
    [navig release]; 


    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:.8]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES]; 
    [CommuneSlider.view removeFromSuperview]; 
    [self.window addSubview:[CommuneDetails view]]; 

    [UIView commitAnimations]; 
} 

和我CommuneSliderController類:

#import "AzurGuideAppDelegate.h" 
#import "CommuneSliderController.h" 
#import "CoverFlowView.h" 
#import "CoverViewController.h" 

#define CVC_VIEW_TAG  999 

@implementation CommuneSliderController 


- (IBAction) goFront:(id) sender { 
    AzurGuideAppDelegate *main = (AzurGuideAppDelegate *)[[UIApplication sharedApplication] delegate]; 
    [main goFront]; 
} 

// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. 
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { 
     // Custom initialization 
    } 
    return self; 
} 

// Implement loadView to create a view hierarchy programmatically, without using a nib. 
- (void)loadView { 
    UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; 
    contentView.backgroundColor = [UIColor whiteColor]; 
    self.view = contentView; 
    [contentView release]; 
    [[UIApplication sharedApplication] setStatusBarHidden:YES]; 

    CoverViewController *cvc = [[CoverViewController alloc] init]; 
    cvc.view.tag = CVC_VIEW_TAG; 
    [self.view addSubview:cvc.view];  
} 
1

如果這是錯誤行:

對[CommuneSlider.view removeFromSuperview]中的某個結構或聯合中的成員視圖的請求;

它似乎表明CommuneSlider沒有「查看」成員。變量的名稱使我認爲它是一個UIControl,而不是UIViewController的子類(它具有視圖屬性)。

你確定你不想要的東西,如:

[CommuneSliderController.view removeFromSuperview]; 
相關問題