0

UIAlertViewNotificationCenterがobservenameで通知を投稿した後、画像のアップロードを再試行するかどうかをユーザーに尋ねるセレクターがあります。

[[NSNotificationCenter defaultCenter] postNotificationName:kNOTIFICATION_PHOTOS_UPLOAD_RETRY object:nil];

ただし、複数の通知を受信したため、受信した通知と同じ数が表示されます。アラートビューを1回だけ表示するためのベストプラクティスはありますか?

4

1 に答える 1

0

ええ、あなたは次のようなことができます:

@interface MyClass
{
    UIAlertView *_myAlertView;
}
@end

@implementation MyClass
...
- (void)myNotificationSelector:(NSNotification *)notification
{
    if (!_myAlertView) {
        _myAlertView = [[UIAlertView alloc] init ...]
        _myAlertView.delegate = self;
        [_myAlertView show];
    }
}
...
@end

UIAlertViewDelegate ハンドラーで、_myAlertView を解放して NO に設定するだけです。

于 2012-10-16T03:49:55.783 に答える