如何增加选取器内的图像视图大小?

时间:2012-09-18 10:01:50

标签: iphone ios ipad

我有一个应用程序,其中一个pickerview与图像。我用这个做了。

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委托方法加载images.i需要在pickerview内增加图像框架。

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;

但是当我试图增加视图的框架时,它的位置只会改变,而不是尺寸。任何人都可以帮我实现这个目标吗?

1 个答案:

答案 0 :(得分:-2)

实现以下pickerview委托方法..

- (CGSize)rowSizeForComponent:(NSInteger)component{

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

   return size;

}