【问题标题】:Xcode Error Instance Method -addAttachment withImageNamed not foundXcode 错误实例方法 - addAttachment withImageNamed not found
【发布时间】:2012-11-12 08:26:40
【问题描述】:

我的项目出现错误,我收到 Xcode 错误实例方法 -addAttachment withImageNamed not found,下面是我的一些代码:

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 个警告。

非常感谢任何帮助。

谢谢

【问题讨论】:

    标签: iphone objective-c ios xcode compiler-errors


    【解决方案1】:

    确保您的类 AttachmentItem 在其头文件中声明 addAttachment:withImageNamed:

    【讨论】:

      【解决方案2】:

      首先:

      • 警告说明了什么?

      我认为正在发生的事情是您应该在 .m 文件中导入 GalleryScrollView。由于您正在尝试使用该特定类中的方法,我猜 Xcode 无法看到它具有-addAttachment:withImageNamed:。这就是它运行正常的原因(该方法实际上存在),但会发出警告,因为从HegakaDragAndDropRecycleBinViewController 你看不到它。另外,您应该treat warnings as errors。这可以帮助您解决在开发后期可能发生的令人讨厌的事情。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-03-12
        • 2017-02-13
        • 2013-02-20
        • 1970-01-01
        • 2019-05-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多