gpt4 book ai didi

iphone - UIViewController的派生类中的

转载 作者:行者123 更新时间:2023-12-01 16:52:58 24 4
gpt4 key购买 nike

提供以下派生类:

#import <UIKit/UIKit.h>

@interface NumberPadViewController : UIViewController {
UIImage *numberPadDoneImageNormal;
UIImage *numberPadDoneImageHighlighted;
UIButton *numberPadDoneButton;
}

@property (nonatomic, retain) UIImage *numberPadDoneImageNormal;
@property (nonatomic, retain) UIImage *numberPadDoneImageHighlighted;
@property (nonatomic, retain) UIButton *numberPadDoneButton;

- (IBAction)numberPadDoneButton:(id)sender;

@end

在此类中使用:
#import <UIKit/UIKit.h>
#import "NumberPadViewController.h"

@interface eatAddViewController : NumberPadViewController <UITextFieldDelegate> {
UITextField *textAmount, *textTips;
}
@property (nonatomic, retain) IBOutlet UISegmentedControl *segAddType;
@property (nonatomic, retain) IBOutlet UITextField *textAmount;
@property (nonatomic, retain) IBOutlet UITextField *textDateTime;
@property (nonatomic, retain) IBOutlet UITextField *textExpenseType;
@property (nonatomic, retain) IBOutlet UITextField *textTips;
@property (nonatomic, retain) IBOutlet UITextField *textTotalAmount;

@end

使用“UITextFieldDelegate”给出以下错误:
2013-01-04 22:54:32.916 ExpenseAccountTracking[39423:c07] -[UITextField object]: unrecognized selector sent to instance 0x8659f60
2013-01-04 22:54:32.916 ExpenseAccountTracking[39423:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITextField object]: unrecognized selector sent to instance 0x8659f60'
*** First throw call stack:
...

在类“eatAddViewController”中将“NumberPadViewController”替换为“UIViewController”可以完美地工作!

有什么线索吗?

我尝试将“UITextFieldDelegate”添加到“NumberPadViewController”中没有任何运气!

这是eatAddViewController.m代码:
#import "eatAddViewController.h"
#import "DateTimeInputView.h"
#import "PickerInputView .h"

@implementation eatAddViewController
@synthesize textAmount, textTips, textTotalAmount, formatter;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
// Do any additional setup after loading the view from its nib.
formatter = [[NSNumberFormatter alloc] init];
formatter.numberStyle = kCFNumberFormatterCurrencyStyle;

DateTimeInputView *dateEntryView = [[DateTimeInputView alloc] init];
self.textDateTime.inputView = dateEntryView;

PickerInputView *expenseTypeView = [[PickerInputView alloc] init];
expenseTypeView.pickerViewOptions = [[NSArray alloc] initWithObjects:NSLocalizedString(@"ExpenseBreakfast", nil), NSLocalizedString(@"ExpenseLunch", nil),
NSLocalizedString(@"ExpenseDiner", nil), NSLocalizedString(@"ExpenseHotel", nil), NSLocalizedString(@"ExpenseOthers",nil), nil];
self.textExpenseType.inputView = expenseTypeView;
self.title = NSLocalizedString(@"Add", nil);

[super viewDidLoad];
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - UITextFieldDelegate

- (void)textFieldDidEndEditing:(UITextField *)textField
{
if (textField == self.textDateTime)
{
}
}

@end

最佳答案

谢谢 Phillip 。我是Xcode的新手(三天;-),对此并不熟悉。问题出在我从网络上截取的某些代码中(NumberPadViewController)。

- (void)textFieldDidBeginEditing:(NSNotification *)note {
// [self updateKeyboardButtonFor:[note object]];
[self updateKeyboardButtonFor:[self findFirstResponderTextField]];
}

如果没有 <UITextFieldDelegate>,则不会调用此函数。因此问题之前就隐藏了。

关于iphone - UIViewController的派生类中的<UITextFieldDelegate>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14168515/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com