Expand UIImageView to full screen from within UITableViewCell(从 UITableViewCell 将 UIImageView 扩展到全屏)
问题描述
我在 UITableViewCell
中有一个 UIImageView
并希望将其展开以填满全屏,我已经设置了我的 UIGestureRecognizer
并正在使用扩展框架的代码:
I have a UIImageView
within a UITableViewCell
and want to expand it to fill the full screen, I have setup my UIGestureRecognizer
and am using this code to expand the frame:
[UIView animateWithDuration:1.0 animations:^{
[self.ImageView setFrame:[[UIScreen mainScreen] applicationFrame]];
}];
但是 UIImageView
只会展开以填充 UITableViewCell
而不会填充全屏.
However the UIImageView
will only expand to fill the UITableViewCell
and does not fill the full screen.
任何帮助将不胜感激.
推荐答案
cells clipsToBounds 设置为 Yes,因此在单元格边界之外的视图将不可见
cells clipsToBounds is set to Yes, so view outside the cell bound will not visible
以下方法将帮助您将单元格中的图像全屏显示,然后将其放回原处.
Following method will help u to get image in cell to full Screen then get it back to same place.
你需要在imageView中添加gestureRecognizer,并将选择器设置为cellImageTapped
You need to add gestureRecognizer to imageView and set selector as cellImageTapped
声明 UIImageView *temptumb,fullview;作为实例变量.
Declare UIImageView *temptumb,fullview; as instance variable.
- (void)cellImageTapped:(UIGestureRecognizer *)gestureRecognizer {
NSLog(@"%@", [gestureRecognizer view]);
//create new image
temptumb=(UIImageView *)gestureRecognizer.view;
//temptumb=thumbnail;
fullview=[[UIImageView alloc]init];
[fullview setContentMode:UIViewContentModeScaleAspectFit];
fullview.image = [(UIImageView *)gestureRecognizer.view image];
CGRect point=[self.view convertRect:gestureRecognizer.view.bounds fromView:gestureRecognizer.view];
[fullview setFrame:point];
[self.view addSubview:fullview];
[UIView animateWithDuration:0.5
animations:^{
[fullview setFrame:CGRectMake(0,
0,
self.view.bounds.size.width,
self.view.bounds.size.height)];
}];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fullimagetapped:)];
singleTap.numberOfTapsRequired = 1;
singleTap.numberOfTouchesRequired = 1;
[fullview addGestureRecognizer:singleTap];
[fullview setUserInteractionEnabled:YES];
}
- (void)fullimagetapped:(UIGestureRecognizer *)gestureRecognizer {
CGRect point=[self.view convertRect:temptumb.bounds fromView:temptumb];
gestureRecognizer.view.backgroundColor=[UIColor clearColor];
[UIView animateWithDuration:0.5
animations:^{
[(UIImageView *)gestureRecognizer.view setFrame:point];
}];
[self performSelector:@selector(animationDone:) withObject:[gestureRecognizer view] afterDelay:0.4];
}
-(void)animationDone:(UIView *)view
{
[fullview removeFromSuperview];
fullview=nil;
}
这篇关于从 UITableViewCell 将 UIImageView 扩展到全屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 UITableViewCell 将 UIImageView 扩展到全屏


- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01