Skip to content

Commit

Permalink
Merge pull request #1 from skywinder/alexperezpaya-master
Browse files Browse the repository at this point in the history
Merging :)
  • Loading branch information
perezpaya committed Jul 22, 2015
2 parents bb5c702 + bf01590 commit 6ec8457
Show file tree
Hide file tree
Showing 129 changed files with 153 additions and 5,973 deletions.
6 changes: 3 additions & 3 deletions ActionSheetPicker-3.0.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 106 additions & 0 deletions BASIC-USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
###Basic Usage

```obj-c
// Inside a IBAction method:

// Create an array of strings you want to show in the picker:
NSArray *colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", @"Orange", nil];

[ActionSheetStringPicker showPickerWithTitle:@"Select a Color"
rows:colors
initialSelection:0
doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) {
NSLog(@"Picker: %@", picker);
NSLog(@"Selected Index: %@", selectedIndex);
NSLog(@"Selected Value: %@", selectedValue);
}
cancelBlock:^(ActionSheetStringPicker *picker) {
NSLog(@"Block Picker Canceled");
}
origin:sender];
// You can also use self.view if you don't have a sender
```
### ActionSheetCustomPicker Customisation
ActionSheetCustomPicker provides the following delegate function that can be used for customisation:
```obj-c
- (void)actionSheetPicker:(AbstractActionSheetPicker *)actionSheetPicker configurePickerView:(UIPickerView *)pickerView;
```
This method is called right before `actionSheetPicker` is presented and it can be used to customize the appearance and properties of the `actionSheetPicker` and the `pickerView` associated with it.


#### Want custom buttons view? Ok!

Example with custom text in Done button:
```obj-c
ActionSheetStringPicker *picker = [[ActionSheetStringPicker alloc] initWithTitle:@"Select a Block" rows:colors initialSelection:0 doneBlock:done cancelBlock:cancel origin:sender];
[picker setDoneButton:[[UIBarButtonItem alloc] initWithTitle:@"My Text" style:UIBarButtonItemStylePlain target:nil action:nil]];
[picker showActionSheetPicker];
```
Example with custom button for cancel button:
```obj-c
ActionSheetStringPicker *picker = [[ActionSheetStringPicker alloc] initWithTitle:@"Select a Block" rows:colors initialSelection:0 doneBlock:done cancelBlock:cancel origin:sender];
UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
[cancelButton setImage:[UIImage imageNamed:@"cancel.png"] forState:UIControlStateNormal];
[cancelButton setFrame:CGRectMake(0, 0, 32, 32)];
[picker setCancelButton:[[UIBarButtonItem alloc] initWithCustomView:cancelButton]];
[picker showActionSheetPicker];
```

#### What about custom buttons callbacks? Let's check it out:

```obj-c
// Inside a IBAction method:

// Create an array of strings you want to show in the picker:
NSArray *colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", @"Orange", nil];

//Create your picker:
ActionSheetStringPicker *colorPicker = [[ActionSheetStringPicker alloc] initWithTitle:@"Select a color"
rows:colors
initialSelection:0
target:nil
successAction:nil
cancelAction:nil
origin:sender];

//You can pass your picker a value on custom button being pressed:
[colorPicker addCustomButtonWithTitle:@"Value" value:@([colors indexOfObject:colors.lastObject])];

//Or you can pass it custom block:
[colorPicker addCustomButtonWithTitle:@"Block" actionBlock:^{
NSLog(@"Custom block invoked");
}];

//If you prefer to send selectors rather than blocks you can use this method:
[colorPicker addCustomButtonWithTitle:@"Selector" target:self selector:@selector(awesomeSelector)];
```
#### Action by clicking outside of the picker:
Use property `tapDismissAction` to specify action, by clicking outside area of the picker:
- `TapActionNone` (default)
- `TapActionSuccess`
- `TapActionCancel`
#### Other customisations:
look at `AbstractActionSheetPicker` properties:
- `toolbar`
- `title`
- `pickerView`
- `viewSize`
- `customButtons`
- `hideCancel` - show or hide cancel button.
- `titleTextAttributes` - default is nil. Used to specify Title Label attributes.
- `attributedTitle` - default is nil. If titleTextAttributes not nil this value ignored.
- `popoverBackgroundViewClass` -allow popover customization on iPad
- `supportedInterfaceOrientations` - You can set your own supportedInterfaceOrientations value to prevent dismissing picker in some special cases.
- `tapDismissAction` - to specify action, by clicking outside area of the picker
- `TapActionNone`
- `TapActionSuccess`
- `TapActionCancel`
1 change: 0 additions & 1 deletion Example Projects/Carthage-example/Cartfile

This file was deleted.

1 change: 0 additions & 1 deletion Example Projects/Carthage-example/Cartfile.resolved

This file was deleted.

Loading

0 comments on commit 6ec8457

Please sign in to comment.