Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone app issue getting result of equation to display on screen
    primarykey
    data
    text
    <p>So I'm trying to create an iphone app that does simple temperature conversion and when I run the code enter my number and hit submit nothing is displayed. I can't seem to find the problem here is my header file</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface ViewController : UIViewController @property (weak, nonatomic) IBOutlet UISegmentedControl *convtype; @property (weak, nonatomic) IBOutlet UITextField *inputtemp; @property (weak, nonatomic) IBOutlet UIButton *submit; @property (weak, nonatomic) IBOutlet UILabel *outputtemp; @end </code></pre> <p>Basically I have a UISegmentedController to select which conversion to do (0 is c to f and 1 is f to c)</p> <p>I have a text field inputtemp for the temperature to convert. Submit is the submit button and a UIlabel outputtemp is where I want the result to be displayed.</p> <p>Not quite sure where this is going wrong here is the rest of my code in the .m file</p> <pre><code>#import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize convtype; @synthesize inputtemp; @synthesize submit; @synthesize outputtemp; - (void)viewDidLoad { inputtemp.keyboardType = UIKeyboardTypeDecimalPad; [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } </code></pre> <p>...</p> <pre><code>- (IBAction)submit:(id)sender { //defines input text float temperature = [[inputtemp text] floatValue]; float sum = 0; //selects formula based on convtype segment control if (convtype.selectedSegmentIndex == 0) { sum = (temperature * 9) / 5 + 32; } else if (convtype.selectedSegmentIndex == 1) { sum = (temperature - 32) * 9 / 5; } //outputs to screen [outputtemp setText:[NSString stringWithFormat:@"%3.2f", sum]]; } @end </code></pre> <p>Is the problem with the setText? I'm not quite sure how to manipulate the ui label</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload