嘿朋友我在实施自定义授权方面遇到问题让我解释一下......
1 - 我有一个pickerview,我已经制作了一个Custom类的pickerView来显示MM / YYYY。
2 - 我在Viewcontroller中有一个Button,我想要的是在pickerView的didselect上更改按钮标题。我实现它就像这样......
在UImonthPickerClass中,我正在实现这样的..
@protocol UIMonthYearPickerDelegate <NSObject>
-(void)pickerView:(UIPickerView *)pickerView didChangeDate:(NSDate*)newDate;
@end
@interface CustomMonthYearPicker : UIPickerView <UIPickerViewDelegate, UIPickerViewDataSource>
@property (nonatomic, weak) id <UIMonthYearPickerDelegate> declareDelegate;
在didSelect中,我这样做......
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
if (self.declareDelegate) {
if ([self.declareDelegate respondsToSelector:@selector(pickerView:didChangeDate:)]) {
[self.declareDelegate pickerView:self didChangeDate:self.date];
}
}
}
在ViewController中我有按钮,我这样做......
@interface AddDetailsViewController ()<UITextFieldDelegate,UIMonthYearPickerDelegate> {
@property (strong, nonatomic) IBOutlet CustomMonthYearPicker *customMonthYear;
}
- (void)viewDidLoad{
[super viewDidLoad];
[customMonthYear setDeclareDelegate:self];
}
#pragma CustomMonthYearProtocol
- (void)pickerView:(UIPickerView *)pickerView didChangeDate:(NSDate *)newDate {
NSString *buttonStr = [NSString stringWithFormat:@"%@",newDate];
[self.btnSelectYear setTitle:buttonStr forState:UIControlStateNormal];
}
但它没有更新didselect上的Button Title ....为什么...... ??请帮助