gpt4 book ai didi

iphone - 静态 UILabel 未显示在 uiview 中

转载 作者:行者123 更新时间:2023-12-03 20:21:06 25 4
gpt4 key购买 nike

我在 Interface Builder 中创建了一些静态 UILabel 文本,但是在运行应用程序时。该标签未显示在应用程序本身中,我不知道为什么。

除了标签之外的所有其他内容(例如文本字段、按钮)都不起作用谁能告诉我出了什么问题吗?

这是在IB中

enter image description here

这是在应用程序中

enter image description here

enter image description here

#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

最佳答案

清理您的项目并再次构建

这是 Xcode 最常见的问题之一。

关于iphone - 静态 UILabel 未显示在 uiview 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7102589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com