0

I hope someone can help with this!

I have been following tutorials on how to build iOS applications and have downloaded an example project.

This project seems to run and compile for everyone else except me!

When I run the app in the simulator, none of the buttons or text fields work. There is no response and no errors.

Has anyone else had this issue?

FirstViewController.h

#import <UIKit/UIKit.h>

@interface FirstViewController : UIViewController {
UITextField *tempTextBox;
UILabel     *calcResult;
}
@property (nonatomic, retain) IBOutlet UILabel *calcResult;
@property (nonatomic, retain) IBOutlet UITextField *tempTextBox;
- (IBAction) degreeConvert:(id)sender;
- (IBAction) backgroundTouchedHideKeyboard:(id)sender;

@end

FirstViewController.m

#import "FirstViewController.h"

@implementation FirstViewController
@synthesize tempTextBox, calcResult;


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

-(void)degreeConvert:(id)sender
{
NSLog(@"IBAction triggered succesfully");
double fahren = [tempTextBox.text doubleValue];
double celcius = (fahren - 32) / 1.8;

[tempTextBox resignFirstResponder];

//create new string with celcius formatting
NSString *convertResult = [[NSString alloc] initWithFormat:@"Celcius:%f", celcius];
//output converted result to calcResult Label
calcResult.text = convertResult;

}

-(void) backgroundTouchedHideKeyboard:(id)sender
{
[tempTextBox resignFirstResponder];

}

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

@end
DerWOK
  • 1,061
  • 9
  • 13
CaledonianCoder
  • 145
  • 1
  • 5

2 Answers2

0

It sounds your buttons are not wired up to the code.

Two ways to find out:

1.) Open up the assistant view in Xcode (button top right, the little butler), Make sure the *.h file of the scene controller show up on the right and your scene on the left. Then hover the mouse over the littel gray circles that show up left of you IBAction lines. Then while you hover over the grey circles, the according button gets highlighted. See "onBtnProtocol" method below.

enter image description here

2.) When you see only the scene in interface builder (i.e. no Assistant View), select one of your buttons, then show up the Connection Inspector. Then you will see, if your button is connected to a method of your controller. See "Touch up Inside" line in the image below.

enter image description here

If wiring is OK from your poin of view, then put some

 NSLog(@"Hey my IBAction was triggered");

log lines in your methods and see if the wiring REALLY works.

If it does not work, then come back with more detail.

Community
  • 1
  • 1
DerWOK
  • 1,061
  • 9
  • 13
  • Wiring seems to be ok, however just seen these errors: Temp Converter[2943] : CGContextSetFillColorWithColor: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update. – CaledonianCoder Jan 06 '14 at 15:26
  • There are multiple errors of a similar nature all involving the CG class – CaledonianCoder Jan 06 '14 at 15:26
  • Also the NSLog shows that the methods are actually being triggered, just nothing happens on screen. Keyboard gets jammed on screen despite using [tempTextBox resignFirstResponder]; to clear :( – CaledonianCoder Jan 06 '14 at 15:31
  • Also just seen this UITextField -webView called. This method is no longer supported with the new text architecture – CaledonianCoder Jan 06 '14 at 15:35
  • OK - My fault. It was just a wild guess. ;-) Unfortunately for people to help you, your job is to post some code. Post the code where the CGContextSetFillColorWithColor is used and post the code of your IBActions. – DerWOK Jan 06 '14 at 15:35
  • For your CGContextSetFillColorWithColor problem see here: http://stackoverflow.com/questions/19940543 - This sounds as if maybe some wrong UI constraints let your images shrink to nothing?! Again: wild guess as we see no code... – DerWOK Jan 06 '14 at 15:37
0

Here you kill your controls in viewDidLoad:

self.tempTextBox = nil;
self.calcResult=nil;

Comment out those lines. And it should work.

DerWOK
  • 1,061
  • 9
  • 13