开发者

uipicker view implementation on action sheet

I have implemented the UIPicker view concept on action sheet, it is working properly but one thing it is not displaying properly that is row index. There is no highlighted row in the picker view.

uipicker view implementation on action sheet

I have uploaded the image. Please give me the solution for it.

Following is the code which I am using:

-(IBAction)clickformedtype:(id)sender
    {
        UIActionSheet *asheet = [[UIActionSheet alloc] initWithTitle:@"Select medication type" delegate:self
                                                   cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Select", nil];
        [asheet showInView:[self.view superview]]; //note: in most cases this would be just self.view, but because I was doing this in a tabBar Application, I use the superview.
        [asheet setFrame:CGRectMake(0, 117, 320, 383)];
        [asheet release];
    }


    -(void)willPresentActionSheet:(UIActionSheet *)actionSheet {

        medicationtypepicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 40, 320, 216)];
        medicationtypepicker.delegate = self;
        medicinetypearray = [[NSMutableArray alloc]initWithObjects:@"ml",@"capsules",@"eyedrops", nil];

        //medicationtypepicker = [[NSMutableArray alloc]initWithObjects:@"ml",@"capsules",@"eyedrops", nil];
        //medicationtypepicker.datePickerMode = ui;

        //Configure picker...
        // [medicationtypepicker setMinuteInterval:1];

        [medicationtypepicker setTag: kDatePickerTag];

        //Add picker to action sheet
        [actionSheet addSubview:medicationtypepicker];

        // [medicationtypepicker release];

        //Gets an array af all of the subviews of our actionSheet
        NSArray *subviews = [actionSheet subviews];

        [[subviews objectAtIndex:SelectButtonIndex] setFrame:CGRectMake(20, 266, 280, 46)]; 
        [[subviews objectAtIndex:CancelButtonIndex] setFrame:CG开发者_如何转开发RectMake(20, 317, 280, 46)];


    }


    - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
    {
        return 1;
    }
    UIPickerView

    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
    {
        return [medicinetypearray count];
    }

    - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
    {
        return [medicinetypearray objectAtIndex:row];
    }

    - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
    {
        medicinetype.text=[medicinetypearray objectAtIndex:row];
        //medicationtypepicker.hidden = YES;

    }

Thanks in advance.


UIPickerView has a property called "showsSelectionIndicator" - set this to YES also set autoresizingMask to UIViewAutoresizingFlexibleWidth as follows...

    mTimePicker.showsSelectionIndicator = YES;          
    mTimePicker.autoresizingMask = UIViewAutoresizingFlexibleWidth;


Try to set property showsSelectionIndicator to YES:

medicationtypepicker.showsSelectionIndicator = YES;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜