Comments (10)
Is there a fix for this?
from iqactionsheetpickerview.
ios8 don`t support
from iqactionsheetpickerview.
Found out that in iOS 8 you`re not allowed to put a pickerview inside an action sheet. You need to put your pickerview in an UIView and present it modally.
I tried to convert IQActionSheetPickerView from action sheet to UIView, but after an hour I ended up moving my pickerviews into my main viewcontroller class and handle everthing there.
from iqactionsheetpickerview.
Could you give me an code-example of how you did this? Much appreciated ..
Thanks in advance.
On Mon, Sep 1, 2014 at 7:24 AM, Knodd [email protected] wrote:
Found out that in iOS 8 you`re not allowed to put a pickerview inside an
action sheet. You need to put your pickerview in an UIView and present it
modally.
I tried to convert IQActionSheetPickerView from action sheet to UIView,
but after an hour I ended up moving my pickerviews into my main
viewcontroller class and handle everthing there.—
Reply to this email directly or view it on GitHub
#6 (comment)
.
from iqactionsheetpickerview.
I moved all functions for pickerview into my main class that I was calling IQActionSheetPickerView from and inserted the data directly into the functions. Then I created a view and animated it onto the screen
.h-file contains
NSArray *YOURDATAARRAY;
@interface MapViewController : UIViewController <UIPickerViewDataSource,UIPickerViewDelegate>{
UIView *ViewForPickerView;
UIPickerView *valuePicker;
UIToolbar *pickerViewToolBar;
}
.m-file contains
-(void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib
//Set up arrays for pickerview
YOURDATAARRAY = [NSArray arrayWithObjects:@"one", @"two", @"three", @"four", nil];
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return YOURDATAARRAY.count;
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return [YOURDATAARRAY objectAtIndex:row];
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
//wait for done button
}
-(void)showPickerView{
//if pickerview is already loaded, animate view off screen and remove
if (ViewForPickerView!=nil) {
[ViewForPickerView removeFromSuperview];
}
//set up pickerview
ViewForPickerView = [[UIView alloc]initWithFrame:CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, 266)];
pickerViewToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerViewToolBar.barStyle = UIBarStyleDefault;//UIBarStyleBlackTranslucent;
[pickerViewToolBar sizeToFit];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(pickerViewCancel:)];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(pickerViewDone:)];
[pickerViewToolBar setItems:[NSArray arrayWithObjects:cancelButton,flexSpace,doneBtn, nil] animated:YES];
[ViewForPickerView addSubview:pickerViewToolBar];
valuePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 44, 320, 216)];
valuePicker.backgroundColor = [UIColor whiteColor];
valuePicker.delegate=self;
valuePicker.dataSource=self;
valuePicker.showsSelectionIndicator=YES;
[valuePicker selectRow:0 inComponent:0 animated:NO];
[ViewForPickerView addSubview:valuePicker];
[self.view addSubview:ViewForPickerView];
[UIView animateWithDuration:0.3 animations:^{ViewForPickerView.frame = CGRectMake(0, self.view.bounds.size.height-266+16, self.view.bounds.size.width, 266);}];
}
-(void)pickerViewDone:(UIBarButtonItem*)barButton{
NSMutableArray *selectedTitles = [[NSMutableArray alloc] init];
NSInteger row = [valuePicker selectedRowInComponent:0];
if (row!= -1)
{
[selectedTitles addObject:[YOURDATAARRAY objectAtIndex:row]];
DataReciever = [YOURDATAARRAY objectAtIndex:row]
else
{
[selectedTitles addObject:[NSNull null]];
}
//animate view off screen and remove
[UIView animateWithDuration:0.3 animations:^{ViewForPickerView.frame = CGRectMake(0, self.view.frame.size.height, self.view.bounds.size.width, 266);} completion:^(BOOL finished){[ViewForPickerView removeFromSuperview];}];
}
-(void)pickerViewCancel:(UIBarButtonItem*)barButton{
//animate view off screen and remove
[UIView animateWithDuration:0.3 animations:^{ViewForPickerView.frame = CGRectMake(0, self.view.frame.size.height, self.view.bounds.size.width, 266);} completion:^(BOOL finished){[ViewForPickerView removeFromSuperview];}];
}
Hope this helps. I was hinking of converting it to a component and putting it on github, but I don't know if I'll have the time anytime soon :-)
from iqactionsheetpickerview.
Some became code and some not... enclosing text in ` removed all line breaks so It was very hard to read. Anybody know how to paste code blocks and keep formatting?
from iqactionsheetpickerview.
Here is an easier solution to this problem.
Use IBActionSheet found here:
https://github.com/ianb821/IBActionSheet
Then in IQActionSheetPickerView.h replace the UIActionSheet with IBActionSheet.
from iqactionsheetpickerview.
hi,ios8 don`t support.
from iqactionsheetpickerview.
KnightMDT, your approach doesn't work for me. Action sheet still init only with title, without content. =(
Now I try approach of Knodd.
from iqactionsheetpickerview.
Fixed CGContextWarnings. Updated to support iOS 8. Internal architecture updated.
from iqactionsheetpickerview.
Related Issues (20)
- Date Format HOT 1
- Incorrect layout on iPad split view (Detailed view controller) HOT 1
- Memory leak
- Method is misspelled HOT 1
- please update version number HOT 1
- iOS 10 support HOT 7
- Button Cancel And Ok Show Not Correct Frame HOT 4
- How to assign array to "titlesForComponents" in swift3. HOT 1
- cancelButton and doneButton position not correct HOT 1
- toolbar not showing HOT 1
- reloadComponent doesn`t work HOT 1
- iPhone X HOT 10
- Could you add a indexPath same as UITableView? HOT 2
- Getting selected value out of the picker to actually use HOT 1
- crashe with signal SIGTRAP
- Cancel Done buttons are unclickable while using in ScrollView with ios 7.1 HOT 4
- Cannot modify delegate. HOT 1
- Any chance of a cocapod? HOT 9
- ActionSheetPicker Title - Cancel - Done Button Titles - ActionToolBar Color HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iqactionsheetpickerview.