Amazon.com Widgets Program 21.1
Welcome, Guest. Please login or register.
Did you miss your activation email?
June 17, 2013, 10:38:30 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Programming in Objective-C, 4th edition
| |-+  Chapter 21
| | |-+  Program 21.1
Pages: [1]   Go Down
Print
Author Topic: Program 21.1  (Read 2801 times)
joemac
Newbie
*
Posts: 2






« on: March 23, 2012, 05:33:14 PM »

iPhone_1ViewController.m

When I push the button labeled 1 in the IOS simulator the click1 method doesn't add the number 1.

I'm guessing the iPhone_1ViewController.m is not written correctly however I don't get any build errors.

Can someone upload a copy of this file?

xcode Version 4.3.1
« Last Edit: March 23, 2012, 07:09:51 PM by joemac » Logged
JackRabbit
Jr. Member
**
Posts: 54



Email




« Reply #1 on: March 26, 2012, 02:42:03 AM »

Greetings joemac.

Here is the iPhone_1ViewController.m file.

Code: (Objective-C)
#import "ViewController.h"

@implementation ViewController

@synthesize display;

-(IBAction) click1
    {
        display.text = @"1";
    }

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

- (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
    }

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    }

@end

If this helps you and your app works like expected, let's talk about what went wrong in the first place and figure out why the correction fixed everything.

JR

Xcode Version 4.3
« Last Edit: March 26, 2012, 06:11:38 AM by JackRabbit » Logged
joemac
Newbie
*
Posts: 2






« Reply #2 on: March 26, 2012, 04:14:25 PM »

Still not working  Huh.

I am using the iPhone 5.1 Simulator.  Xcode 4.3.1

When selecting the 1 button on the Simulator the button turns blue.  The #1 however still doesn't show up on the top right.

Logged
seerex
Full Member
***
Posts: 177


Email




« Reply #3 on: March 27, 2012, 07:54:27 AM »

Hi mate,

First, are you sure the connections are set up properly? Try to ctrl-click (i think its ctrl-click, it's defo some key + click) on the button and the label, and see wether they are set to connect to the proper item.

If they both seem rightfully connected, you could place an NSLog call in the IBAction method linked to your button, and if that NSLog call gets printed out, you know that the action method get's called correctly.

If the action method gets called, it should work and the error lies in the way you are changing the label text. Make sure you did it properly, as in the book.

Let me know how it works out
Logged

Best Regards -
J.B.J
If you think i helped you could return the favor Wink

Subscribe to my channel on youtube: http://www.youtube.com/user/JBJProgramming

My apps:
- iTap Fruits (all countries)
- Toilet-Quiz (Denmark only)
- Zoo Kids (Denmark only)
- Diablo Item Database (All countries)
JackRabbit
Jr. Member
**
Posts: 54



Email




« Reply #4 on: April 01, 2012, 04:22:15 AM »

Greetings joemac

seerex gave some concrete advice to you. I am curious how it worked out. Give us an update.

JR
Logged
wadechen
Newbie
*
Posts: 2


Email




« Reply #5 on: November 23, 2012, 12:31:18 AM »

I met the same problem here
because I linked the button twice
then I rebuild another button and link
it works ~
check the debugger

Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.