1

当我按下链接到该视图的按钮时出现以下错误。为什么?

2012-12-09 18:44:52.634 LNG[42719:c07] Unknown class DensityViewController in Interface Builder file.
2012-12-09 18:44:52.645 LNG[42719:c07] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x71bcb90> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key ethaneText.'
*** First throw call stack:
(0x1c93012 0x10d0e7e 0x1d1bfb1 0xb7d711 0xafeec8 0xafe9b7 0xb29428 0x2350cc 0x10e4663 0x1c8e45a 0x233bcf 0xf8e37 0xf9418 0xf9648 0xf9882 0x105235 0x3043d2 0x1024f3 0x102777 0x1027b7 0x46dfe2 0x45fad9 0x45fb54 0x10e4705 0x1b920 0x1b8b8 0xdc671 0xdcbcf 0xdbd38 0x4b33f 0x4b552 0x293aa 0x1acf8 0x1beedf9 0x1beead0 0x1c08bf5 0x1c08962 0x1c39bb6 0x1c38f44 0x1c38e1b 0x1bed7e3 0x1bed668 0x1865c 0x2c1d 0x2b45)
libc++abi.dylib: terminate called throwing an exception
(lldb) 

密度视图控制器.h:

#import <UIKit/UIKit.h>
#import "FlipsideViewController.h"
#import "MainViewController.h"
@interface DensityViewController : UIViewController
[More code]

和密度视图控制器.m

#import "DensityViewController.h"

@interface DensityViewController ()

@end

@implementation DensityViewController
[More code]

最后是我的 XIB 的照片(IK 看起来很糟糕,WIP) 在此处输入图像描述

我能做些什么来纠正这个错误?编辑:全.m

#import "DensityViewController.h"

@interface DensityViewController()

@end

@implementation DensityViewController
@synthesize tempratureText, methaneText, ethaneText, propaneText, nbutaneText,     ibutaneText,npetaneText, ipetaneText, nhexaneText, nitrogenText, oxygenText, outputText;

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

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

-(IBAction)textFieldReturn:(id)sender
{
[sender resignFirstResponder];
}
-(IBAction)backgroundTouched:(id)sender
{
[tempratureText resignFirstResponder];
[methaneText resignFirstResponder];
[ethaneText resignFirstResponder];
[propaneText resignFirstResponder];
[nbutaneText resignFirstResponder];
[ibutaneText resignFirstResponder];
[npetaneText resignFirstResponder];
[ipetaneText resignFirstResponder];
[nhexaneText resignFirstResponder];
[oxygenText resignFirstResponder];
[nitrogenText resignFirstResponder];

}

- (void)updateConversionLabel:(UITextField *)textField
{

NSNumberFormatter *fmt1  =  [NSNumberFormatter new]; //Temp
NSNumberFormatter *fmt2  =  [NSNumberFormatter new]; //Methane
NSNumberFormatter *fmt3  =  [NSNumberFormatter new]; //Ethane
NSNumberFormatter *fmt4  =  [NSNumberFormatter new]; //Propane
NSNumberFormatter *fmt5  =  [NSNumberFormatter new]; //n-butane
NSNumberFormatter *fmt6  =  [NSNumberFormatter new]; //i-butane
NSNumberFormatter *fmt7  =  [NSNumberFormatter new]; //n-petane
NSNumberFormatter *fmt8  =  [NSNumberFormatter new]; //i-petane
NSNumberFormatter *fmt9  =  [NSNumberFormatter new]; //n-hexane
NSNumberFormatter *fmt10 =  [NSNumberFormatter new]; //nitrogen
NSNumberFormatter *fmt11 =  [NSNumberFormatter new]; //oxygen


double temprature = [fmt1  numberFromString:tempratureText.text].doubleValue;
double methane    = [fmt2  numberFromString:methaneText.text   ].doubleValue;
double ethane     = [fmt3  numberFromString:ethaneText.text    ].doubleValue;
double propane    = [fmt4  numberFromString:propaneText.text   ].doubleValue;
double nbutane    = [fmt5  numberFromString:nbutaneText.text   ].doubleValue;
double ibutane    = [fmt6  numberFromString:ibutaneText.text   ].doubleValue;
double npetane    = [fmt7  numberFromString:npetaneText.text   ].doubleValue;
double ipetane    = [fmt8  numberFromString:ipetaneText.text   ].doubleValue;
double nhexane    = [fmt9  numberFromString:nhexaneText.text   ].doubleValue;
double nitrogen   = [fmt10 numberFromString:nitrogenText.text  ].doubleValue;
double oxygen     = [fmt11 numberFromString:oxygenText.text    ].doubleValue;

double Xi = 1;
double Mi = 2;
double Vi = 3;
double Vc = 4;
//Do not mind this, just placeholders for some other stuffs. 

double over1 = Xi * Mi;
double under1 = Xi * Vi - Vc;


double result =  over1 / under1;


NSString *resultString = [[NSString alloc]initWithFormat:@" Test %f", result];
/*
outputText.text = resultString;
*/
if (temprature == 0 || methane == 0 || ethane == 0 || propane == 0 || nbutane == 0 || ibutane == 0 || oxygen == 0 || npetane == 0 || ipetane == 0 || nhexane == 0 || nitrogen == 0)
{
    outputText.text = @"Please enter all values";
} else
{
    outputText.text = resultString;
}
}

@end
4

1 回答 1

0

试图删除界面中的 nibe 并重新从头开始。因为您可能会从其他项目中复制 nib,所以有时 xcode 会以这种方式运行。它肯定会起作用。

于 2012-12-10T18:11:50.073 回答