Detect when a User takes a Screenshot

后端 未结 3 1201
死守一世寂寞
死守一世寂寞 2021-01-30 15:26

I am looking for way for my app to receive a notification when the user takes a screenshot either with Command-Shift-3 or Command-Shift-4.

An e

3条回答
  •  醉话见心
    2021-01-30 15:46

    youll have to register an object to recieve the system notification when a user takes a screen shot

    so:

    [[NSNotificationCenter defaultCenter] addObserver: theObjectToRecieveTheNotification selector:@selector(theMethodToPerformWhenNotificationIsRecieved) name:@"theNameOftheScreenCapturedNotification" object: optionallyAnObjectOrArgumentThatIsPassedToTheMethodToBecalled];
    

    not sure what the notification name is but it's probably out there.

    don't forget to unregister yourself as well in dealloc:

    [[NSNotificationCenter defaultCenter] removeObserver:self];

提交回复
热议问题