【问题标题】:Change owner of subView?更改子视图的所有者?
【发布时间】:2015-03-26 18:35:49
【问题描述】:

我正在尝试实现一个动画,其中UITableViewCell 的图像展开以填满整个视图。我已经掌握了基础知识,但图像卡在navigationBar 后面。如何更改UIImageView 使其成为当前视图的subView

这是我目前拥有的动画:

UITableViewCell *cell = [_tableView cellForRowAtIndexPath:indexPath];
UIImageView *imageView = [cell viewWithTag:1];
UIView *cellView = [cell viewWithTag:2];
[UIView animateWithDuration:0.5
                      delay:0
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^(void)
                     {

                         imageView.contentMode = UIViewContentModeScaleAspectFill;
                         [cellView bringSubviewToFront:imageView];
                         [imageView setFrame:CGRectMake(0, -64, self.view.frame.size.width, self.view.frame.size.height+64)];
                     }
                 completion:^(BOOL finished)
                     {
                         if(finished)
                         {
                             [self.navigationController presentModalViewController:readerViewController animated:YES];
                         }
                     }];

【问题讨论】:

  • 只需致电[someOtherView addSubview:imageView];。这会将其从当前父视图中移除,并将其添加到您选择的任何“someOtherView”中。

标签: ios objective-c uitableview uiimageview


【解决方案1】:

问题在于表格在顶栏下方延伸。

在情节提要中选择您的表格视图控制器,然后在属性检查器中取消选择顶栏下的扩展边缘属性。

这会将表格的顶部限制在导航栏下方。

如果您希望它位于导航栏的前面,您可以隐藏导航栏,然后可以看到图像。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-20
    • 1970-01-01
    • 1970-01-01
    • 2013-05-11
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    相关资源
    最近更新 更多