1

カスタム QLPreviewController 実装があるため、ユーザーに表示されるボタンとそのアクションを制御できます。viewWillAppearカスタム クラスのメソッドに次のコードを追加しました。

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

    UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(openWithPressed:)];
    UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissPressed:)];
    [self.navigationItem setRightBarButtonItem:rightBarButtonItem];
    [self.navigationItem setLeftBarButtonItem:leftBarButtonItem];
    [rightBarButtonItem release];
    [leftBarButtonItem release];
}

プレビューアにはカスタム ボタンが表示され、期待どおりに機能します。
ユーザーが「ホーム」ボタンをクリックすると、問題が発生します。UIApplication.doEventsメソッドが set ボタン メソッドを呼び出し、navigationItem元の値に (元のハンドラーを使用して) リセットするように継ぎ目があります。
これを防ぐにはどうすればよいですか、またはこれらのイベントを自分で処理して、独自のカスタム ボタンで上書きするにはどうすればよいですか?

4

1 に答える 1

2

私はこれと同じ問題を抱えていました。アプリケーションが再びアクティブになったときに呼び出される NSNotification を設定し、ナビゲーション バーを希望どおりにリセットする必要があります。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(configureNavBar)
                                             name:UIApplicationDidBecomeActiveNotification object:nil];
于 2012-05-18T20:28:27.837 に答える