嗨,我尝试创建一个委托以将数据从 tableInterval 回传到 ElectricMeter uiViewController,但该委托仍不会触发。这是我的代码 tableInterval h.file
@protocol updateIntervalDelegate
@required
-(void)intervalRefresh:(NSString *)interval;
@end
@interface tableInterval : UITableViewController<UITextFieldDelegate, MBProgressHUDDelegate>
{
IBOutlet UILabel *IntervalLabel;
IBOutlet UILabel *EndLabel;
IBOutlet UILabel *StartLabel;
MBProgressHUD *HUD;
IBOutlet UIDatePicker *datePicker;
IBOutlet UITableViewCell *IntervalCell;
__unsafe_unretained id <updateIntervalDelegate> delegate;
}
@property (nonatomic, strong) UIActionSheet *actionSheet;
@property (nonatomic, strong) UITextField *interval;
@property (nonatomic, retain) NSURL *url;
@property (nonatomic, retain) NSString *StartDate;
@property (nonatomic, retain) NSString *EndDate;
@property(nonatomic, assign)id <updateIntervalDelegate> delegate;
@property (retain, nonatomic) NSString* noId;
-(IBAction)PreviousView:(id)sender;
-(IBAction)updateInterval:(id)sender;
@end
在 m.file 中
@synthesize actionSheet,interval,url,noId,StartDate,EndDate,delegate;
[delegate intervalRefresh:interval.text];
调用委托方法。
所以这是在实现类 .h 文件中
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "tableInterval.h"
#import "ListMeterCell.h"
#import "PopoverView.h"
#import "MBProgressHUD.h"
@interface ElectricMeterController : UIViewController<UITableViewDelegate,UITableViewDataSource, PopoverViewDelegate,MBProgressHUDDelegate,updateIntervalDelegate> {
PopoverView *pv;
MBProgressHUD *HUD;
}
在 .m 文件中
-(void)intervalRefresh:(NSString *)interval{
NSLog(@"delegate fired!");
NSDictionary *copy=[updatedInfo mutableCopy];
[copy setValue:interval forKey:@"interval"];
[temp removeObjectAtIndex:path.row];
[temp insertObject:copy atIndex:path.row];
[self.MeterList reloadData];
}
所以nslog没有被解雇,为什么?我在这里错过了什么吗?