2012-11-12 63 views
0

我有在我的項目一個錯誤,我得到的Xcode錯誤實例方法-addAttachment withImageNamed沒有找到,下面是我的一些代碼:Xcode的錯誤實例方法-addAttachment withImageNamed沒有找到

HegakaDragAndDropRecycleBinViewController.h

@interface HegakaDragAndDropRecycleBinViewController : UIViewController { 
IBOutlet GalleryScrollView *gallery; 

} 
-(NSString*)withImageNamed; 

@property (nonatomic, retain) IBOutlet GalleryScrollView *gallery; 
@end 

HegakaDragAndDropRecycleBinViewController.m

#import "HegakaDragAndDropRecycleBinViewController.h" 
#import "AttachmentItem.h" 

@implementation HegakaDragAndDropRecycleBinViewController 

@synthesize gallery; 

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

- (void)didReceiveMemoryWarning 
{ 
// Releases the view if it doesn't have a superview. 
[super didReceiveMemoryWarning]; 

// Release any cached data, images, etc that aren't in use. 
} 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
self.gallery.mainView = self.view; 


AttachmentItem *item = [[AttachmentItem alloc] initWithData:1 data:nil]; 
[self.gallery addAttachment:item withImageNamed:@"recyclebin"]; 
[self.gallery addAttachment:item withImageNamed:@"canadian-maple"]; 
[self.gallery addAttachment:item withImageNamed:@"light-cherry"]; 
[self.gallery addAttachment:item withImageNamed:@"mozambique-wenge"]; 
[self.gallery addAttachment:item withImageNamed:@"canadian-maple"]; 

[item release]; 
} 

- (void)viewDidUnload 
{ 
[super viewDidUnload]; 
// Release any retained subviews of the main view. 
// e.g. self.myOutlet = nil; 
} 

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

@end 

我得到我的警報在履行線,在這裏警告:

[self.gallery addAttachment:item withImageNamed:@"recyclebin"]; 
[self.gallery addAttachment:item withImageNamed:@"canadian-maple"]; 
[self.gallery addAttachment:item withImageNamed:@"light-cherry"]; 
[self.gallery addAttachment:item withImageNamed:@"mozambique-wenge"]; 
[self.gallery addAttachment:item withImageNamed:@"canadian-maple"]; 

該項目仍然運行,但有這6個警告。

任何援助非常感謝。

感謝

回答

1

確保您的類AttachmentItem在其頭文件中聲明addAttachment:withImageNamed:

0

首先:

  • 是什麼警告說?

我認爲正在發生的事情是,你應該導入GalleryScrollView在.m文件。既然你要使用的方法從特定的類,我想Xcode的,是不是能看到它-addAttachment:withImageNamed:。這就是爲什麼它運行正常(該方法存在的事實),但給出了一個警告,因爲從HegakaDragAndDropRecycleBinViewController你看不到它。另外,你應該treat warnings as errors。這可以幫助你解決在開發過程中可能發生的骯髒事情。

相關問題