gpt4 book ai didi

ios - 无法识别的选择器发送到实例(UIStepper)

转载 作者:行者123 更新时间:2023-11-29 03:38:59 25 4
gpt4 key购买 nike

好吧,我知道有很多这样的问题,因为我已经查看并尝试了一些解决方案。然而,我尝试过的许多方法都不起作用,或者答案对我来说太难以理解——我是一名新开发人员,这是我的第一个应用程序。我通过学习此时不该做什么来学习。

我在 UIStepper stepperValueChanged 设置中出现“无法识别的选择器发送到实例错误”。这是给我的错误消息的内容:

[DetailViewController stepperValueChanged]: unrecognized selector sent to instance 0x8637630

我可能会为此感到心碎,但我无法真正理解这里发生了什么 - 到目前为止我唯一的猜测是假设它与我的代码中stepperValueChanged存在的唯一点有关 - 在DetailViewController.h,如下所示:

@interface DetailViewController : UIViewController <UISplitViewControllerDelegate>
{
// Create GUI parameters for text fields, text labels, and the stepper:
IBOutlet UITextField *value1;
IBOutlet UITextField *value2;
IBOutlet UITextField *value3;
IBOutlet UISwitch *double_precision;
IBOutlet UILabel *value1_type;
IBOutlet UILabel *value2_type;
IBOutlet UILabel *value3_type;
IBOutlet UILabel *deriv_units;
IBOutlet UILabel *units;
IBOutlet UILabel *result;
IBOutlet UIStepper *stepper;
}

// Define properties of the above GUI parameters:
@property (nonatomic, retain) UITextField *value1;
@property (nonatomic, retain) UITextField *value2;
@property (nonatomic, retain) UITextField *value3;
@property (nonatomic, retain) UILabel *value1_type;
@property (nonatomic, retain) UILabel *value2_type;
@property (nonatomic, retain) UILabel *value3_type;
@property (nonatomic, retain) UILabel *deriv_units;
@property (nonatomic, retain) UILabel *units;
@property (nonatomic, retain) UILabel *result;

// Setup property as instance of UIStepper:
@property (nonatomic, strong) IBOutlet UIStepper *stepper;

// Setup NSString instance for segue linking:
@property (nonatomic, strong) NSString *equationName;

@property (strong, nonatomic) id detailItem;
@property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel;

// IBActions for the Calculate button and UIStepper instance:
- (IBAction)Calculate:(id)sender;
- (IBAction)stepperValueChanged:(id)sender;
- (IBAction)double_precision:(id)sender;

@end

知道这里发生了什么吗?我没有太多线索,如果有人能在解决这个问题时帮助向我解释这里到底发生了什么,我将不胜感激。

如果您需要实现文件的内容,请告诉我;我将对其进行编辑。

.m文件的相关区域:

@interface DetailViewController ()

@property (strong, nonatomic) UIPopoverController *masterPopoverController;
- (void)configureView;
@end

@implementation DetailViewController

// Synthesize an instance of NSString for segue linking:
@synthesize equationName = _equationName;;

// Synthesize all other variables:

@synthesize value1 = _value1;
@synthesize value2 = _value2;
@synthesize value3 = _value3;
@synthesize value1_type = _value1_type;
@synthesize value2_type = _value2_type;
@synthesize value3_type = _value3_type;
@synthesize deriv_units = _deriv_units;
@synthesize result = _result;
@synthesize units = _units;
@synthesize stepper = _stepper;

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self configureView];
self.title = _equationName;
self.stepper.stepValue = 1;
self.stepper.autorepeat = NO;
self.stepper.continuous = YES;
self.stepper.wraps = YES;
int eqNum;
if ((_equationName = @"Energy-Frequency Relation"))
{
eqNum = 1;
self.stepper.minimumValue = 1;
self.stepper.maximumValue = 3;
}
else if ((_equationName = @"Energy-Frequency-Wavelength Relation"))
{
eqNum = 2;
self.stepper.minimumValue = 1;
self.stepper.maximumValue = 4;
}
// Take _equationName quantization and use it in a switch case to determine the formula that IBAction will use:
if (dflt)
{
switch (eqNum)
{
case 1:
if ((stepper.value = 1))
{
// Change deriv_units appropriately:
self.deriv_units.text = @"Energy (Joules)";
// This is a Planck's constant calculation, we hide the second variable as the constant
// is stored:
self.value2.hidden = YES;
self.value2_type.hidden = YES;
self.value3.hidden = YES;
self.value3_type.hidden = YES;
// Now we set up the parameters of the first entry variable:
self.value1_type.text = @"Frequency (in Hz)";
double frequency = [value1.text doubleValue];
double Planck = 6.626069e-34;
double energy = Planck * frequency;
// Now we set up the return field to return results:
NSString* resultIntermediate = [NSString stringWithFormat:@"%f", energy];
self.units.text = @"J";
}

// Identical function statements under ViewDidLoad truncated
}


bool dflt;
-(IBAction)KeyboardGoAway:(id)sender
{
[self.value1 resignFirstResponder];
[self.value1 resignFirstResponder];
[self.value1 resignFirstResponder];
}


-(IBAction)double_precision:(id)sender
{
// Sets double-float 'truth' value depending on state of UISwitch:
if (double_precision.on)
{
dflt = TRUE;
}
else
{
dflt = FALSE;
}
}

#pragma mark - Calculation runtime

-(IBAction)Calculate:(id)sender
{
// Assigns numerical information to _equationName data -
// switch case can only handle integer literals
// Also handles stepper incrementation and UILabel/UITextView hiding
NSString* resultIntermediate;
self.result.text = resultIntermediate;
}

最佳答案

尾随的冒号有所不同。您的操作方法是 stepperValueChanged:,但从错误消息来看,您似乎将步进器连接到了 stepperValueChanged

关于ios - 无法识别的选择器发送到实例(UIStepper),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18733781/

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