2012-11-12 39 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。这可以帮助你解决在开发过程中可能发生的肮脏事情。

相关问题