【发布时间】:2015-10-27 02:33:12
【问题描述】:
所以,我有包含缩略图的重复视图,一旦按下缩略图,缩略图 ID 就会作为标签发送。
有了这些信息,我想得到那个视图的子视图的框架;
- (IBAction)thumbPressed:(id)sender {
NSLog(@"Thumb %i pressed", (int)[sender tag]);
for (int i = 0; i < _thumbCounter; i++) {
if (i == [sender tag]) {
NSLog(@"thumb view %i", i);
//Up To HERE
break;
}
}
// [self moveToVideoControllerWithInfoID:[NSString stringWithFormat:@"%li", (long)[sender tag]]];
}
对于要绘制的缩略图,它们是按照 JSON 检索的随机顺序绘制的。
按钮
UIButton *thumbButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[thumbButton addTarget:self
action:@selector(thumbPressed:)
forControlEvents:UIControlEventTouchUpInside];
thumbButton.frame = CGRectMake(0, 0, _thumbView.frame.size.width, _thumbView.frame.size.height);
thumbButton.tag = _thumbCounter;
[_thumbView addSubview:thumbButton];
我要获取框架的子视图
NSString *string = [NSString stringWithFormat:@"***.jpg",Link];
NSURL * imageURL = [NSURL URLWithString:string];
NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage * image = [UIImage imageWithData:imageData];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(thumbGap, thumbGap, thumbHeight - 5, thumbHeight - 5)];
imageView.image = image;
[_thumbView addSubview:imageView];
缩略图壳的绘制位置
_thumbView = [[ThumbView alloc] initWithFrame:CGRectMake(0, margin, _scrollView.frame.size.width, thumbHeight)];
_thumbView.backgroundColor = [UIColor whiteColor];
_thumbView.thumbId = _thumbCounter;
[_scrollView addSubview:_thumbView];
_thumbview 是添加了 thumbId 的 UIVIEW 类
一旦按下该按钮,我如何才能在 _thumbview 中找到 imageView 框架(记住有多个)。
【问题讨论】:
-
我只是想确定你的逻辑。如果你能把它画成
- /ul> 格式的树形图会更容易,你能帮忙吗?
标签: ios objective-c uiview frame subview