我是编程新手,在以下方面我已经被困了一段时间:
当我运行附加的代码时,一切似乎都正常,然后进度条再次开始计数。控制台不断打印失效确认字符串,但计时器似乎一直在滚动。我感谢您的帮助。
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize doneYet;
@synthesize cooking;
@synthesize hidebutton;
- (void)viewDidLoad;
{
[super viewDidLoad];
[doneYet setProgress:doneYet.progress=0.0];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setDoneYet:nil];
[self setHidebutton:nil];
[self setCooking:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
-(void)startTimer
{CurrentTimer=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerFired) userInfo:Nil repeats:YES];}
-(void)timerFired
{ if (doneYet.progress<1) {
[doneYet setProgress:doneYet.progress+0.1];
}
else if (doneYet.progress=1)
{
(void) [CurrentTimer invalidate];
NSLog(@"invalidated CurrentTimer");
hidebutton.hidden = FALSE;
cooking.hidden = TRUE;
[doneYet setProgress:doneYet.progress=0.0];
}
}
- (IBAction)Eggtimer:(id)sender
{
[self startTimer];
hidebutton.hidden = TRUE;
cooking.hidden = FALSE;
;}
@end