我的.m文件中出现“不完整的实现”错误,但我无法弄清楚如何修复它。我会发布.h和.m文件,如果你能给我提示如何解决这个问题。感谢。
显然,我需要提供更多细节,或者我不能发布问题,因为帖子主要包含代码,所以这只是一些虚线。
.h文件
#import <UIKit/UIKit.h>
@interface BlogViewController : UIViewController <UIPickerViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate>
- (IBAction)selectPicturePressed:(id)sender;
- (IBAction)blogPost:(id)sender;
@property (weak, nonatomic) IBOutlet UITextView *commentTextField;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (nonatomic, strong) NSString *username;
@end
.m文件
#import "BlogViewController.h"
#import <Parse/Parse.h>
#import "SWRevealViewController.h"
#import "PhotoViewController.h"
@interface BlogViewController ()
-(void)showErrorView:(NSString *)errorMsg;
@end
@implementation BlogViewController **//Incomplete Implementation**
@synthesize imageView = _imageView;
@synthesize username = _username;
@synthesize commentTextField = _commentTextField;
答案 0 :(得分:2)
IBActions只是具有语法糖的常规函数,用于将它们连接到界面构建器,因此您必须在.m文件中实现它们
.m文件:
- (IBAction)selectPicturePressed:(id)sender {
// code here
}
- (IBAction)blogPost:(id)sender {
// and here
}
答案 1 :(得分:1)
在给出Incomplete Implementation
错误的行上,您可以获得有关您遗失的内容的更多详细信息。
你没有粘贴所有.m
,所以任何人都猜你错过了什么,但是,你的.h
声明了你必须实现的2种方法和3种协议。
您的.m
文件必须包含以下两种方法的方法主体:
- (IBAction)selectPicturePressed:(id)sender;
- (IBAction)blogPost:(id)sender;
可能,你已经在这里有了这些,特别是如果这些是通过Ctrl + Dragging从界面构建器生成的。
但是,您还必须至少包括您声明的协议中的所有必需方法。
UIPickerViewDelegate
protocol official documentation UINavigationControllerDelegate
protocol official documentation UIImagePickerControllerDelegate
protocol official documentation. (我对这些协议并不完全熟悉,并且不确定他们确实有任何@required
方法。)
您的.m
还有一个私人界面,它声明了您必须在implementation
中实施的方法。
-(void)showErrorView:(NSString *)errorMsg;
您在私有接口中声明了此方法,因此请务必同时实现此方法。
无论您缺少什么,Xcode都会绝对告诉您是否只需单击错误/警告。 Xcode将为您提供其期望在您的实现中找到的方法的名称,但不能。