-
Notifications
You must be signed in to change notification settings - Fork 0
How to Use
Currently it only works with the UITextField object.
If you are developing in an ARC project add the following flag in the build files: -fno-objc-arc
The usage is pretty simple:
- Initialize the UIAccessoryView object
- Set both datasource and delegate properties to your ViewController
- Set the view as the fields InputAccessoryView with the field method setInputAccessoryView
- Use an array to store all your fields
- Call the method UIAccessoryView reloadData
- Done!
It uses delegate methods, the same way UITableView does it.
Include the files UIAccessoryView.h and UIAccessoryView.m in your xcode project.
Then you should include the header file: #import "UIAccessoryView.h"
Initialize the controller as bellow:
UIAccessoryView *v = [[UIAccessoryView alloc] init]; v.delegate = self; v.dataSource = self;
[field1 setInputAccessoryView:v]; [field2 setInputAccessoryView:v]; [field3 setInputAccessoryView:v];
dataSource = [[NSMutableArray alloc] init]; [dataSource addObject:field1]; [dataSource addObject:field2]; [dataSource addObject:field3]; [v reloadData];
Bellow are the delegate methods:
-
(void) didPressedDoneButton { [_field resignFirstResponder]; }
-
(NSInteger) numberOfFields { return [dataSource count]; }
-
(UITextField *)fieldForRowAtIndex:(int)index { UITextField *f = [dataSource objectAtIndex:index];
return f; }
Done!
You can also open the xcode project and check the files RooViewController.h and RooViewController.m for a practical example.