// 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];
}
// 先感谢您。