-1

可能重复:
iOS6 UIAlertView.title 坏了?

// btnstartgame.enabled = yes 但它不应该被启用,我不知道为什么,请帮忙。

//附言。此代码将一些已保存的字符串提供给 2 个标签,然后应检查它们是否相同,尽管由于某种原因它们永远不会相同。(他们 = lblTeamOne 和 lblTeamTwo)

@synthesize lblTeamOne;
@synthesize lblTeamTwo;
@synthesize sliderTeamOneOutlet;
@synthesize sliderTeamTwoOutlet;
@synthesize btnStartGame;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
    // Custom initialization
}
return self;
}
-(void)loadTeams:(NSString*)location:(UILabel*)lblname
{

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *loadstring = [defaults objectForKey:location];
lblname.text = loadstring;
}
-(void)sliderdisplay:(UISlider *)sliderOutlet :(UILabel *)lblName
{

if(0 < sliderOutlet.value && 1 >= sliderOutlet.value)
{
    [self loadTeams:@"save1" :lblName];

}
if(1 < sliderOutlet.value && 2 >= sliderOutlet.value)
{
    [self loadTeams:@"save2" :lblName];

}
if(2 < sliderOutlet.value && 3 >= sliderOutlet.value)
{
    [self loadTeams:@"save3" :lblName];

}
if(3 < sliderOutlet.value && 4 >= sliderOutlet.value)
{
    [self loadTeams:@"save4" :lblName];

}
if(4 < sliderOutlet.value && 5 >= sliderOutlet.value)
{
    [self loadTeams:@"save5" :lblName];

}
if(5 < sliderOutlet.value && 6 >= sliderOutlet.value)
{
    [self loadTeams:@"save6" :lblName];

}
if(6 < sliderOutlet.value && 7 >= sliderOutlet.value)
{
    [self loadTeams:@"save7" :lblName];

}
if(7 < sliderOutlet.value && 8 >= sliderOutlet.value)
{
    [self loadTeams:@"save8" :lblName];

}
}
-(void)loadMaximum
{

int teamAmount = [[[NSUserDefaults standardUserDefaults] objectForKey:@"teamAmount"] intValue];
NSNumber *yourNumber = [NSNumber numberWithInt:teamAmount];
float sliderMaximumDigital = [yourNumber floatValue];
[sliderTeamOneOutlet setMaximumValue:sliderMaximumDigital];
[sliderTeamTwoOutlet setMaximumValue:sliderMaximumDigital];
}

- (void)viewDidLoad
{
[super viewDidLoad];
[self loadMaximum];
[self loadTeams:@"save1" :lblTeamOne];
[self loadTeams:@"save1" :lblTeamTwo];


if(lblTeamOne == lblTeamTwo)
{
    btnStartGame.enabled = NO;
}
if(lblTeamOne.text == lblTeamTwo.text)
{
    btnStartGame.enabled = NO;
}
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}

- (IBAction)sliderTeamOneAction:(id)sender
{
[self sliderdisplay:sliderTeamOneOutlet :lblTeamOne];
}

- (IBAction)sliderTeamTwoAction:(id)sender
{
    [self sliderdisplay:sliderTeamTwoOutlet :lblTeamTwo];
}

// 先感谢您。

4

2 回答 2

3

要比较字符串,请执行以下操作:

[string1 isEqualToString:string2]

如果您使用 == 您实际上是在比较内存中的位置(通常会有所不同)而不是字符串的内容。

于 2012-09-28T11:10:27.737 回答
0

您可以使用此代码 Ben 是对的,我给您一个链接,您可以在其中找到您的解决方案。另一个人也面临同样的问题。所以您也可以在这里找到您的解决方案 -

iOS6 UIAlertView.title 坏了?

于 2012-09-28T11:43:54.663 回答