Invalid UITextField tag

It upsets me. I am a beginner programmer and cannot understand why the text does not change.

Here is my method that should set the text of UITextField:

-(void)updateDays:(NSInteger)days
{
    NSString* daysString = [[NSString alloc] initWithFormat:@"%d", days];
    [daysTextField setText:daysString];
    [daysString release];
}

For some reason, nothing happens.

Help me please!

+3
source share
4 answers

At any time, when you have disappointment in the lines “why this line doesn’t work”, use the debugger or simply add an NSLog before this to print the relevant data:

NSLog(@"updateDays: %@ %@ <= %@", daysTextField, daysTextField.text, daysString);

Then you know that line (a) is executed, (b) the variables are the ones you consider them, and (c) the values ​​are reasonable.

+6
source

, , , UITextField .

, , UITextField nil. .xib .

+4

, . , . , , IBOutlet .

0

.

: (in viewdidload)

UITextView *tv = [[UITextView alloc]initWithFrame:CGRectMake(0,0,320,50)]];
tv.text = @"12345";
tv.textColor=[UIColor blackColor];
[self.view addSubView:tv];

(12345) ;

, , textColor , ;

, .

xcode 4.2 iphone5.0simulator.

0

All Articles