如何在每次應用返回背景時設置滾動條的默認值?
滾動條如下:
- (IBAction)slider1:(id)sender
{
UISlider *slider = (UISlider *)sender; //declare slider
NSLog(@"%f",slider.value;
}
如何設置?
添加 observer 到 UIApplicationWillEnterForegroundNotification
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
- (void)willEnterForeground:(NSNotification *)n {
self.slider.value = 0.0f;
}