Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update read me, add installMenuHandlerForObject usage

  • Loading branch information...
commit 598fc7dfd8eed64347f0dbd45ceb36970f0c6d1e 1 parent d0fa58b
Peter Steinberger authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 README.md
9 README.md
View
@@ -5,12 +5,15 @@ A block based UIMenuItem subclass.
The inflexible @selector based approach in UIMenuItem was driving me crazy.
I searched quite a while for a block-based UIMenuItem, but couldn't find one.
-So finally, I sat down and wrote my own implementation for [my iOS PDF framework PSKit](http://pspdfkit.com).
+So finally, I sat down and wrote my own implementation for [my iOS PDF framework PSPDFKit](http://pspdfkit.com).
If you are as annoyed about the missing target/action pattern, as I am, you will *love* this. [Also read the in-depth article on my website.](http://petersteinberger.com/blog/2012/hacking-block-support-into-uimenuitem/)
## How to use
``` objective-c
+ // one time-call needed to prepare the block based PSMenuItem handler.
+ [PSMenuItem installMenuHandlerForObject:button];
+
PSMenuItem *actionItem = [[PSMenuItem alloc] initWithTitle:@"Action 1" block:^{
[[[UIAlertView alloc] initWithTitle:@"Message" message:@"From a block!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
}];
@@ -31,7 +34,7 @@ If you are as annoyed about the missing target/action pattern, as I am, you will
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
```
-PSMenuItem uses ARC and is tested with Xcode 4.4 and 4.5DP3 (iOS 4.3+)
+PSMenuItem uses ARC and is tested with Xcode 4.4 and 4.5 (iOS 4.3+)
The code looks a bit scary and involves swizzling certain methods, but it's actually not that bad. No private API is used, and it's highly unlikely that Apple ever changes something as basic as the UIResponder chain.
@@ -44,4 +47,4 @@ I'd love a thank you tweet if you find this useful.
## License
-PSMenuItem is available under the MIT license. See the LICENSE file for more info.
+PSMenuItem is available under the MIT license. See the LICENSE file for more info.
Please sign in to comment.
Something went wrong with that request. Please try again.