diff --git a/README.md b/README.md index 07fd3c2..12ef3b0 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ If you want to have total control over what the **Previous** and **Next** button 1. Find all text fields and editable text views in the key window 2. Sort them using their frame origin vertical position +If you need notification of **Previous** and **Next** button presses, use the optional `changeBlock` property to add a block-based callback (but beware of `self` retain cycles!). + License ======= The MIT License (MIT) @@ -38,4 +40,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/XCDFormInputAccessoryView/XCDFormInputAccessoryView.h b/XCDFormInputAccessoryView/XCDFormInputAccessoryView.h index 0ba942e..82ff21a 100644 --- a/XCDFormInputAccessoryView/XCDFormInputAccessoryView.h +++ b/XCDFormInputAccessoryView/XCDFormInputAccessoryView.h @@ -7,6 +7,8 @@ #import +typedef void(^XCDFormInputAccessoryViewChangeBlock)(UIResponder *newFirstResponder); + @interface XCDFormInputAccessoryView : UIView - (id) initWithResponders:(NSArray *)responders; // Objects must be UIResponder instances @@ -15,6 +17,8 @@ @property (nonatomic, assign) BOOL hasDoneButton; // Defaults to YES on iPhone, NO on iPad +@property (nonatomic, copy) XCDFormInputAccessoryViewChangeBlock changeBlock; + - (void) setHasDoneButton:(BOOL)hasDoneButton animated:(BOOL)animated; @end diff --git a/XCDFormInputAccessoryView/XCDFormInputAccessoryView.m b/XCDFormInputAccessoryView/XCDFormInputAccessoryView.m index 06a1fc2..ef03a34 100644 --- a/XCDFormInputAccessoryView/XCDFormInputAccessoryView.m +++ b/XCDFormInputAccessoryView/XCDFormInputAccessoryView.m @@ -155,6 +155,9 @@ - (void) selectAdjacentResponder:(UISegmentedControl *)sender if (adjacentResponderIndex >= 0 && adjacentResponderIndex < (NSInteger)[self.responders count]) adjacentResponder = [self.responders objectAtIndex:adjacentResponderIndex]; + if (self.changeBlock) + self.changeBlock(adjacentResponder); + [adjacentResponder becomeFirstResponder]; }