开发者

UIPicker first appears black

I have the following code to draw a custom picker. Unfortunately when the view is first drawn is black. Only when I touch it does it appear.

How can I fix this?

Here is the relevant code in the UIView:

- (void)drawRect:(CGRect)rect 
{
    [self createPicker];
    [self addSubview:dPicker];
//[dPicker reloadComponent:1];
}

-(void) createPicker
{
    dPicker = [[UIPickerView alloc] initWithFrame:CGRectZero];
    CGSize pickerSize = [dPicker sizeThatFits:CGSizeZero];
    dPicker.frame = [self pickerFrameWithSize:pickerSize];
    dPicker.delegate=self;
    dPicker.showsSelectionIndicator = YES;
    dPicker.hidden=NO;
}


- (CGRect)pickerFrameWithSize:(CGSize)size
{
    CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
    CGRect pickerRect = CGRectMake( 0.0,
    开发者_如何学Python                           screenRect.size.height - 44.0 - size.height,
                               size.width,
                               size.height);
    return pickerRect;
}


Fixed it. Called the subview from UIViewController instead of the the UIView

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜