Is it possible to refresh a timer in a Today Widget?

前端 未结 2 771
清酒与你
清酒与你 2021-02-14 20:45

I was wondering is it possible to update the text label of a timer in a today widget. I took a look around but nothing helped me.

2条回答
  •  没有蜡笔的小新
    2021-02-14 20:55

    I know this is a Swift question, but I found it looking for Objective-C code and so others may too.

    -(void) viewDidLoad
    {
        [NSTimer scheduledTimerWithTimeInterval:1 // update more than once a second to appear in sync with the system clock
                                         target:self
                                       selector:@selector(updateUi:)
                                       userInfo:nil
                                        repeats:YES];
    
    }
    
    
    -(void) updateUi:(NSTimer *)timer 
    {
       // Update Widget UI as required
    }
    

提交回复
热议问题