Amazon.com Widgets Ex 21.2 nothing on display... need some explanations!
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 23, 2013, 02:24:16 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
|-+  Old Stuff
| |-+  Chapter Study
| | |-+  Chapter 21 - Writing iPhone Applications
| | | |-+  Ex 21.2 nothing on display... need some explanations!
Pages: [1]   Go Down
Print
Author Topic: Ex 21.2 nothing on display... need some explanations!  (Read 613 times)
kras_87
Newbie
*
Posts: 1






« on: April 22, 2012, 07:36:02 AM »

Hi All!
im new in objective C programming but i've read an excellent book by Steve.
well... my problem is that my frac calculator displays nothing. i was trying to find where is the problem can be and wrote little test program:

Code: (Objective-C)
#import <UIKit/UIKit.h>

@interface SenderViewController : UIViewController {

UILabel *display1;
NSMutableString *aString;

}

@property(retain, nonatomic) IBOutlet UILabel *display1;
@property(retain, nonatomic) NSMutableString *aString;

-(IBAction)click1:(UIButton *) sender;

@end

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

@implementation SenderViewController


@synthesize display1, aString;


-(IBAction)click1:(UIButton *) sender
{

[aString appendFormat:@"%i",sender.tag];
display1.text = aString;
}


- (void)dealloc
{
[display1 release];
[super dealloc];
}

@end



this prog have button, display and should return tag button on display... but nothing happens. it is a simple analog of two methods from exercise 21.2:
-(void) processDigit: (int) digit & -(IBAction) clickDigit: (UIButton *) sender

can you give me some advices?!


i find my problem but dont know how to fix it. its all because displayString = null all time
Code: (Objective-C)
-(void) processDigit: (int) digit;
{
currentNumber = currentNumber * 10 + digit;
[displayString appendString: [NSString stringWithFormat: @"%i", digit]];  //cannot assign displayString here...
display.text = displayString;

}

« Last Edit: April 22, 2012, 02:22:00 PM by kras_87 » Logged
jackfig
Newbie
*
Posts: 2






« Reply #1 on: May 24, 2012, 10:50:28 PM »

I just came across the same problem - nothing on the display.  Go into the Interface Builder (click on Fraction_CalculatorViewController.xib).   Check the attributes for the label (display) and make sure the text color is different (contrasting) the background color.  e.g. set background color to white and text color to black.

I don't recall ever setting the text color, but when I checked it, it was set to white which did not show against the light blue color of the display.
« Last Edit: May 25, 2012, 10:48:14 AM by jackfig » Logged
mlad travkov
Newbie
*
Posts: 1


Email




« Reply #2 on: March 13, 2013, 12:40:16 PM »

dude thx u so much )))
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.