0

返信フィールドを使用して通知から入力を取得するにはどうすればよいですか。ドキュメントには何も見つかりませんでした

これが私の現在のコードです。ユーザーからの応答を得るには何が必要ですか?

#import "AppDelegate.h"

@implementation AppDelegate
@synthesize nTitle;
@synthesize nMessage;

- (IBAction)showNotification:(id)sender{
    NSUserNotification *notification = [[NSUserNotification alloc] init];
    notification.title = [nTitle stringValue];
    notification.informativeText = [nMessage stringValue];
    notification.soundName = NSUserNotificationDefaultSoundName;

    [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
    [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
}
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{
    return YES;
}

@end

通知センターの最新情報とドキュメントはどこで入手できますか?

4

2 に答える 2

1

「NSUserNotificationCenter」、「NSUserNotification」、および「NSUserNotificationCenterDelegate Protocol Reference」を検索すると、Xcode 5 のインライン ドキュメントで必要なすべてのドキュメントを見つけることができます。

ユーザー通知には返信フィールドはありませんが、アクション ボタンを追加して、ユーザーがこのボタンまたは既定のボタンをクリックして通知を閉じるかどうかをテストできます。ただし、通知センターの設定で、ユーザーがアラートではなくバナーを受信することを選択した場合、バナーにはボタンがないため、応答が通知されることはありません。

于 2013-11-11T10:01:38.223 に答える