2

別のシングルトン クラスによって生成されたUISliderに従ってを更新したい。notification

sondDuration=audioPlayer.currentItem.asset.duration;
songDurationinSeconds=CMTimeGetSeconds(sondDuration);
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTime:) userInfo:nil repeats:YES];

これが私の通知世代です。

UISliderこれによると、別の方法で更新する方法をViewController教えてください。

4

2 に答える 2

2

そのためにデリゲートメソッドを使用できます

以下のように:

http://www.roostersoftstudios.com/2011/04/12/simple-delegate-tutorial-for-ios-development/

于 2013-05-07T06:16:03.543 に答える
1

UISlider を更新するビューコントローラーに NSNotification を追加する必要があると思います

ビューコントローラーで

[[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(receiveSliderUpdate:) 
    name:@"UpdateSlider"
    object:nil];

- (void) receiveSliderUpdate:(NSNotification *) notification
{
    // [notification name] should always be @"UpdateSlider"
    // unless you use this method for observation of other notifications
    // as well.

    if ([[notification name] isEqualToString:@"UpdateSlider"])
        // do something with your slider
}

コントローラーにコードを追加して、View Controller に通知します

[[NSNotificationCenter defaultCenter] 
        postNotificationName:@"UpdateSlider" 
        object:self];
于 2013-05-07T06:15:16.363 に答える