0
我已經創建了委託方法,並在Xcode的低版本中工作,但不能在Xcode 6.1中工作。如何在iOS 8中創建自定義委託?
其示值誤差找不到協議聲明NSObject的
嘗試代碼: .h文件中
@class ReportCell;
@protocol keyboardDelegate <NSObject>
@optional
- (BOOL)leaveKeyboard:(ReportCell *)cell ;
@end
#import <UIKit/UIKit.h>
@interface ReportCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UIImageView *imgReport;
@property (strong, nonatomic) IBOutlet UITextField *txtReport;
@property (strong, nonatomic) IBOutlet UIView *viewReport;
@property (nonatomic, assign) id <keyboardDelegate> delegate;
@end
.m文件
#import "ReportCell.h"
@implementation ReportCell
- (void)awakeFromNib
{
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[_delegate leaveKeyboard:self];
[self.superview endEditing:YES];
[super touchesBegan:touches withEvent:event];
}
-Excellant answer這對我們非常有幫助,謝謝! – Hardy 2015-04-08 06:43:34