Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa 将NSTimer链接到NSProgressIndicator_Cocoa_Nstimer_Nsprogressindicator - Fatal编程技术网

Cocoa 将NSTimer链接到NSProgressIndicator

Cocoa 将NSTimer链接到NSProgressIndicator,cocoa,nstimer,nsprogressindicator,Cocoa,Nstimer,Nsprogressindicator,我需要制作一个NSTimer,它将告诉另一个类在10秒内开火,我还想用它来制作一个确定的NSProgressIndicator的动画。我还需要知道如何将我的不确定进度指标更改为确定。我找到了一份关于这个的苹果文档,不过更深入的解释会有所帮助。从不确定到确定n程序指示器您可以在IB中更改。选择您的进度指示器,转到属性检查器,取消选中不确定复选框,如下所示: [progressIndicatorOutlet setDoubleValue:10]; -(void)callAfter10sec:(NS

我需要制作一个
NSTimer
,它将告诉另一个类在10秒内开火,我还想用它来制作一个确定的
NSProgressIndicator
的动画。我还需要知道如何将我的不确定进度指标更改为确定。我找到了一份关于这个的苹果文档,不过更深入的解释会有所帮助。

从不确定到确定
n程序指示器
您可以在IB中更改。选择您的进度指示器,转到属性检查器,取消选中不确定复选框,如下所示:

[progressIndicatorOutlet setDoubleValue:10];
-(void)callAfter10sec:(NSTimer *)time {
    // Do what You want here

}

也可以通过编程方式完成:

[progressIndicatorOutlet setIndeterminate:NO];
注意:ProgressIndicatorRoutlet是您的
NSProgressIndicator
outlet,因此不要忘记
IBOutlet


确定程序指示器动画:

设置和更改值非常简单,如下所示:

[progressIndicatorOutlet setDoubleValue:10];
-(void)callAfter10sec:(NSTimer *)time {
    // Do what You want here

}
注意:ProgressIndicatorRoutlet是您的
NSProgressIndicator
outlet,因此不要忘记
IBOutlet


n计时器:

简单计时器示例:

//Place this where You want to call class after 10 sec. (for example: when button pressed)
//It will call class with name callAfter10sec after 10 sec. Place in there what You need to do. 

[NSTimer scheduledTimerWithTimeInterval:10.0
                                 target:self
                               selector:@selector(callAfter10sec:)
                               userInfo:nil
                                repeats:YES];
别忘了添加我在评论中提到的类,如下所示:

[progressIndicatorOutlet setDoubleValue:10];
-(void)callAfter10sec:(NSTimer *)time {
    // Do what You want here

}

从“不确定”到“确定”
NSProgressIndicator
您可以在IB中更改。选择您的progressIndicator并转到属性检查器,然后取消选中“不确定”复选框,如下所示:

[progressIndicatorOutlet setDoubleValue:10];
-(void)callAfter10sec:(NSTimer *)time {
    // Do what You want here

}

也可以通过编程方式完成:

[progressIndicatorOutlet setIndeterminate:NO];
注意:ProgressIndicatorRoutlet是您的
NSProgressIndicator
outlet,因此不要忘记
IBOutlet


确定程序指示器动画:

设置和更改值非常简单,如下所示:

[progressIndicatorOutlet setDoubleValue:10];
-(void)callAfter10sec:(NSTimer *)time {
    // Do what You want here

}
注意:ProgressIndicatorRoutlet是您的
NSProgressIndicator
outlet,因此不要忘记
IBOutlet


n计时器:

简单计时器示例:

//Place this where You want to call class after 10 sec. (for example: when button pressed)
//It will call class with name callAfter10sec after 10 sec. Place in there what You need to do. 

[NSTimer scheduledTimerWithTimeInterval:10.0
                                 target:self
                               selector:@selector(callAfter10sec:)
                               userInfo:nil
                                repeats:YES];
别忘了添加我在评论中提到的类,如下所示:

[progressIndicatorOutlet setDoubleValue:10];
-(void)callAfter10sec:(NSTimer *)time {
    // Do what You want here

}
希望能有帮助

使用以下方法,我们可以实现预期目标

NSInteger progressValue;
NSTimer *timerObject;

progressValue = progressMaxValue;

timerObject = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(incrementProgressBar) userInfo:nil repeats:YES];

[timerObject fire];
[self.progressBar setMinValue:progressMinValue]; 
[self.progressBar setMaxValue:progressMaxValue];
[self.progressBar setDoubleValue:progressValue];

- (void)incrementProgressBar {
    // Increment the progress bar value by 1
    [self.progressBar incrementBy:1.0];
    progressValue--;
    [self.progressBar setDoubleValue:progressValue];
}
希望能有帮助

使用以下方法,我们可以实现预期目标

NSInteger progressValue;
NSTimer *timerObject;

progressValue = progressMaxValue;

timerObject = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(incrementProgressBar) userInfo:nil repeats:YES];

[timerObject fire];
[self.progressBar setMinValue:progressMinValue]; 
[self.progressBar setMaxValue:progressMaxValue];
[self.progressBar setDoubleValue:progressValue];

- (void)incrementProgressBar {
    // Increment the progress bar value by 1
    [self.progressBar incrementBy:1.0];
    progressValue--;
    [self.progressBar setDoubleValue:progressValue];
}

谢谢阿洛特,这真的很有帮助。谢谢阿洛特,这真的很有帮助。