由TableView的章节标题隐藏的子视图

时间:2014-05-29 11:02:29

标签: ios uitableview

我有一个表视图控制器,我正在添加一个加载视图(这是另一个UIView)。我将此加载视图作为子视图添加到tableview,然后将其删除。

我面临的问题是作为子视图添加的加载视图隐藏在部分标题下,并且在单元格上可见。

我该如何纠正?

我的代码添加了加载视图 -

@implementation RIDECustomActivityIndicator

- (id) initWithParentView:(UIView *)parentView withText:(NSString *)text{
    self = [super init];

    _parentView = parentView;

    _loadingView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)];
    _loadingView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    _loadingView.clipsToBounds = YES;
    _loadingView.layer.cornerRadius = 10.0;

    _activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    _activityView.frame = CGRectMake(65, 40, _activityView.bounds.size.width, _activityView.bounds.size.height);
    [_loadingView addSubview:_activityView];

    _loadingLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)];
    _loadingLabel.backgroundColor = [UIColor clearColor];
    _loadingLabel.textColor = [UIColor whiteColor];
    _loadingLabel.adjustsFontSizeToFitWidth = YES;
    _loadingLabel.textAlignment = NSTextAlignmentCenter;
    _loadingLabel.text = text;
    [_loadingView addSubview:_loadingLabel];

    [_parentView addSubview:_loadingView];

    [_loadingView setHidden:YES];

    return self;
}

- (void) show {
    [_activityView startAnimating];
    [_loadingView setHidden:NO];
    [_parentView setUserInteractionEnabled:NO];
}

- (void) hide {
    [_activityView stopAnimating];
    [_loadingView setHidden:YES];
    [_parentView setUserInteractionEnabled:YES];
}

要初始化,我将表格视图作为parentView传递,然后我可以showhide。当parentView是正常的UIView时,这种情况很有效。

0 个答案:

没有答案