Я создал несколько статических текстов UILabel в Интерфейсном Разработчике, но при запуске приложения.ярлык не отображается в самом приложении, я не знаю почему.
все другие вещи, такие как текстовое поле, кнопки, кроме ярлыка, не работают, кто-нибудь может мне посоветовать, что пошло не так?
Это в IB
это в приложении
#import "SettingsViewController.h"
@implementation SettingsViewController
@synthesize drinkLimitText;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
appDelegate = (DrinkTabsAndNavAppDelegate *)[[UIApplication sharedApplication] delegate];
[super viewDidLoad];
NSLog(@"subView:%d",[self.view.subviews count]);
}
- (void) viewWillAppear:(BOOL)animated {
if ([appDelegate.drinkLimit floatValue] >= 0)
drinkLimitText.text = [NSString stringWithFormat:@"%.0f", [appDelegate.drinkLimit floatValue]];
else
drinkLimitText.text = @"0";
[super viewWillAppear:animated];
}
- (IBAction)textFieldDoneEditing:(id)sender{
NSDecimalNumber *tempValue = [[NSDecimalNumber alloc] initWithString:drinkLimitText.text];
if (tempValue == [NSDecimalNumber notANumber] || [tempValue doubleValue] < 0) {
NSString *msg = [[NSString alloc] initWithFormat: @"Make sure to enter a positive number."];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Hang on..."
message:msg
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
[msg release];
} else {
[sender resignFirstResponder];
[self updateDrinkLimit];
}
[tempValue release];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)updateDrinkLimit {
NSDecimalNumber *newLimit = [[NSDecimalNumber alloc] initWithString:[drinkLimitText text]];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([newLimit floatValue] >= 0) {
[defaults setFloat:[newLimit floatValue] forKey:kDrinkLimitKey];
appDelegate.drinkLimit = newLimit;
} else {
[defaults setFloat:0 forKey:kDrinkLimitKey];
appDelegate.drinkLimit = 0;
}
[newLimit release];
}
- (IBAction)openOntrackWebsite {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.ontrack.org.au/"]];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[drinkLimitText release];
[super dealloc];
}
@end