__block NSMutableArray *array = [NSMutableArray array];
@autoreleasepool {
for(int i = 1;i < 100;i++) {
[array addObject:[NSNumber numberWithInteger:i]];
}
}
self.pickerView = [[DFPickerView alloc] initWithStyle:DFPickerViewStyleDark]; // DFPickerViewStyleLight
self.pickerView.animationDuration = 0.30f; // defaults to 0.23f
[self.view addSubview:self.pickerView];
[self.pickerView showInView:self.view withAnimations:nil completion:nil objects:array converter:^NSString *(id object) {
return [[object stringValue] stringByAppendingString:@" pcs."];
} selection:^(NSInteger selectedIndex, id selectedObject) {
NSLog(@"Selecting object: %@ at index: %i", selectedObject, selectedIndex);
} cancel:^{
array = nil;
self.pickerView = nil;
NSLog(@"Cancelled");
} done:^(NSInteger selectedIndex, id selectedObject) {
array = nil;
self.pickerView = nil;
NSLog(@"Completed with object: %@ at index: %i", selectedObject, selectedIndex);
}];
iOS 7 及以上版本。
duffpod, [email protected]
DFPickerView 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。