0

私はピッカービューが画像と共にあるアプリケーションを持っています.私はこれでそれをしました.`

picker1=[[UIPickerView alloc] init];
        picker1.frame= CGRectMake(30,90,155,316);




        picker1.delegate = self;
        picker1.dataSource = self;
        picker1.showsSelectionIndicator = YES;

        picker1.tag = 1;
        [self.view addsubview:picker1];

そして、viewForRowデリゲートメソッドを使用して画像をロードしています。ピッカービュー内の画像フレームを増やす必要があります。

UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png",[self.array objectAtIndex:row]]];

    UIImageView *icon = [[UIImageView alloc] initWithImage:img];        
    //temp.frame = CGRectMake(170, 0, 30, 30);




    UIView *tmpView = [[[UIView alloc] initWithFrame:CGRectMake(155,75,95,35)] autorelease];
    [tmpView insertSubview:icon atIndex:0];
    picker1.backgroundColor = [UIColor clearColor];
    [(UIView*)[[picker1 subviews] objectAtIndex:2] setAlpha:0.0f];
    [(UIView*)[[picker1 subviews] objectAtIndex:0] setAlpha:0.0f];
    [(UIView*)[[picker1 subviews] objectAtIndex:1] setAlpha:0.0f];
    [(UIView*)[[picker1 subviews] objectAtIndex:3] setAlpha:0.0f];

    [tmpView setUserInteractionEnabled:NO];

    [tmpView setBackgroundColor:[UIColor clearColor]];
    [tmpView setTag:row];

    return tmpView;

しかし、ビューのフレームを大きくしようとすると、サイズではなく位置が変わるだけです。誰かがこれを達成するのを手伝ってくれますか?

4

1 に答える 1

-2

次の pickerview デリゲート メソッドを実装します。

- (CGSize)rowSizeForComponent:(NSInteger)component{

    CGSize size = CGSizeMake(320, 60); //input ur custom size

   return size;

}
于 2012-09-18T10:09:09.003 に答える