я добавил UIView
к пользовательской ячейке UITableView
в раскадровке, и я к нему доступ, как это:UITableViewCell viewWithTag получить кадр UIView неприятности
UIView *customView = (UIView *)[cell viewWithTag:CELL_CUSTOM_VIEW_TAG];
NSLog(@"%f", customView.frame.size.width);
Но я его ширину 0.0000
. Я обращаюсь к нему неправильно?
EDIT: Вот мой метод полной cellForRow:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
UIImageView *customImageView = (UIImageView *)[cell viewWithTag:CELL_IMAGE_VIEW_TAG];
customImageView.image = [UIImage imageNamed:@"foo.jpg"];
//down is the code why I need the frame of it
//I'm trying to make a right border to this UIImageView:
CGRect imageViewFrame = customImageView.frame;
CALayer *imageViewRightBorder = [self rightBorderWithColour:[UIColor blackColor] forView:imageViewFrame];
[customImageView.layer addSublayer:imageViewRightBorder];
return cell;
}
А вот мой метод для правой границы до ImageView:
- (CALayer *)rightBorderWithColour:(UIColor *)color forView:(CGRect)viewFrame {
CALayer *rightBorder = [CALayer layer];
rightBorder.frame = CGRectMake(viewFrame.size.width, 0.0f, 1.0f, viewFrame.size.height);
rightBorder.backgroundColor = [color colorWithAlphaComponent:1.0f].CGColor;
return rightBorder;
}
Где вы установили рамку из uiview? – Woodstock
в раскадровке –
@AlickDikan Проверено ли 'customView'' nil'? Может быть, тег установлен неправильно? – Amar