ios - 在从 UIPickerView 选择的 NSTimer 的 UILabel 中显示秒数

标签 ios objective-c uiview uilabel nstimer

如何在 NSTimer 的标签中显示秒数?

imageVC.h

@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

imageVC.m

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];


        imageViewController *pickerView = [[imageViewController alloc] init];
            [NSTimer scheduledTimerWithTimeInterval:10
                                             target:self
                                           selector:@selector(timeout)
                                           userInfo:nil
                                            repeats:NO];
        }];

        }
    }

如有任何帮助,我们将不胜感激。

谢谢

最佳答案

尝试将超时值设置为您想要的最大值。

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

-(void) timeout {
if (timeCount==0) {
    [timer invalidate];

} else {
    timeCount = timeCount-1;
    timeLabel.text = [NSString stringWithFormat:@"%d",timeCount];
       }
 }

关于ios - 在从 UIPickerView 选择的 NSTimer 的 UILabel 中显示秒数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31566613/

相关文章:

ios - 如何将UIWebView放入框架中

ios 错误终止 -[__NSArrayM setRoleHistorys :]:

ios - 如何在 Phonegap iOS 中更改键盘

objective-c - 使一系列按钮的响应都不同

iphone - 检查 UIViewController 是否有任何文本字段、 TextView 或标签更改..?

ios - 在委托(delegate)回调中包装手动 UItableViewCell 取消选择

iphone - 如何自定义 NSArray 字符串的排序顺序?

ios - NSLayoutConstraints 出现问题并以编程方式使用自动布局时,UIViews 停留在 (0,0)

ios - UIView subview 放置

ios - UIView 作为 UIImageView 的父级