yenbekbay / ayslidingpickerview Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED] Implementation of a picker view that can be shown by either tapping on or panning the navigation bar
License: MIT License
[DEPRECATED] Implementation of a picker view that can be shown by either tapping on or panning the navigation bar
License: MIT License
When you add it to a view. The back button will no longer work. Is there anyway to make the frame of the Recognisers smaller?
Hi,
My use case is quite simple:
I have 2 view controllers let say A, B (A is in a navigation controller). Flow is:
NSMutableArray*
).viewWillAppear
I check if number of records > 0 then I add them to AYSlidingPickerViewThe problem is:
[A.navigationController pushViewController:animated:]
then AYSlidingPickerView works normally.[A presentViewController:animated:completion:]
then when B is dismissed the AYSlidingPickerView will be displayed above A so I can not do anything with A anymore.My fix:
For now to fix it I put AYSlidingPickerView to back again in [A viewDidAppear:]
as shown in code below but I feel like a hack so I hope you can take a look and suggest a better fix.
Code of A:
#import "ViewController.h"
#import "ItemViewController.h"
#import <AYSlidingPickerView/AYSlidingPickerView.h>
@interface ViewController () {
NSMutableArray *texts;
AYSlidingPickerView *pickerView;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
texts = [[NSMutableArray alloc] init];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if ([texts count] > 0) {
pickerView = [AYSlidingPickerView sharedInstance];
NSMutableArray *items = [[NSMutableArray alloc] initWithCapacity:[texts count]];
for (NSString *s in texts) {
AYSlidingPickerViewItem *item = [[AYSlidingPickerViewItem alloc] initWithTitle:s handler:^(BOOL completed) {
self.navigationController.title = s;
}];
[items addObject:item];
}
pickerView.mainView = self.view;
pickerView.items = items;
pickerView.selectedIndex = 0;
pickerView.closeOnSelection = YES;
[pickerView addGestureRecognizersToNavigationBar:self.navigationController.navigationBar];
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// To ensure picker view is sent to back
[[UIApplication sharedApplication].delegate.window sendSubviewToBack:pickerView];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[pickerView removeGestureRecognizersFromNavigationBar:self.navigationController.navigationBar];
}
- (IBAction)addItem:(id)sender {
ItemViewController *ivc = [self.storyboard instantiateViewControllerWithIdentifier:@"ItemViewController"];
ivc.texts = texts;
[self presentViewController:ivc animated:YES completion:nil];
// [self.navigationController pushViewController:ivc animated:YES];
}
Code of B:
#import "ItemViewController.h"
@interface ItemViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textToAdd;
@end
@implementation ItemViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterFullStyle];
self.textToAdd.text = [formatter stringFromDate:[NSDate date]];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)addItemTapped:(id)sender {
[self.texts addObject:self.textToAdd.text];
[self dismissViewControllerAnimated:YES completion:nil];
// [self.navigationController popViewControllerAnimated:YES];
}
@end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.