Git Product home page Git Product logo

Comments (10)

mevansjr avatar mevansjr commented on September 16, 2024

Is there a fix for this?

from iqactionsheetpickerview.

zhouyuan24 avatar zhouyuan24 commented on September 16, 2024

ios8 don`t support

from iqactionsheetpickerview.

Knodd avatar Knodd commented on September 16, 2024

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.

mevansjr avatar mevansjr commented on September 16, 2024

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.

Knodd avatar Knodd commented on September 16, 2024

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.

Knodd avatar Knodd commented on September 16, 2024

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.

KnightMDT avatar KnightMDT commented on September 16, 2024

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.

edison9888 avatar edison9888 commented on September 16, 2024

hi,ios8 don`t support.

from iqactionsheetpickerview.

AleksBidnik avatar AleksBidnik commented on September 16, 2024

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.

hackiftekhar avatar hackiftekhar commented on September 16, 2024

Fixed CGContextWarnings. Updated to support iOS 8. Internal architecture updated.

from iqactionsheetpickerview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.