我在标签中显示文件传输进度。但是当fileprogress
数据字符串出现时,directionstring
文本根据其位置闪烁。如何阻止附加字符串的闪烁?
directionstring = @"uploaging file";
fileprogress = transferring rate EX.(25.00 MB of 50.00 MB);
message = [message stringByAppendingString:[NSString stringWithFormat:@"%@%@",fileprogress,directionstring]];
progressLabel.text = message;
答案 0 :(得分:0)
我做了一个例子(用计时器来模拟进度),测试它,文本没有闪烁
@implementation ViewController
{
IBOutlet UILabel *_progressLabel;
NSInteger _percent;
}
- (void)showProgress
{
_percent = 0;
[NSTimer scheduledTimerWithTimeInterval:0.2
target:self
selector:@selector(updateProgress:)
userInfo:nil
repeats:YES];
}
- (void)updateProgress:(NSTimer *)timer {
NSString *directionstring = @" uploading file";
NSString *fileprogress = [NSString stringWithFormat:@"%ld of 100", (long)_percent++];
NSString *message = [NSString stringWithFormat:@"%@%@", fileprogress, directionstring];
_progressLabel.text = message;
}
@end