Moving content of UITableViewCell on tap

旧时模样 提交于 2020-01-14 04:52:16

问题


If anyone have Google+ App can certainly understand what I'm trying to implement.
(explained here: UIViewController Containment with animation like Google+)

I think it has something related with the new effect in iOS 7 Calendar App.
(explained here: Recreating iOS 7 Calendar UIView Animation)

-

This is a common animation effect that I'm seeing in many apps these days.

Months ago, the fellow Rob tried to help me with this his answer:

Now I was trying to implement it but there's a problem. Images explains better:


INITIAL STATE



WHAT HAPPEN WITH CURRENT IMPLEMENTATION



WHAT SHOULD HAPPEN

I've created a super simple project that shows the implementation (few lines).

Can someone help me to find where's the problem?

REPO: https://github.com/socksz/MovingTableViewCellContent


回答1:


The problem is that you're trying to change the view's frame with Auto Layout on. You can't do that. The Auto Layout system will overwrite your changes. Try turning off Auto Layout in your storyboard and you'll see that it works.

So your options are:

  1. Don't use Auto Layout
  2. Use/manipulate constraints instead of frames.

For (2) you can just go into the storyboard and set up width and height constraints on the container view and it will work. If fixed size isn't the exact behavior you want, you'll need to be more explicit in your requirements.

The default constraints you're getting now are attached to the parent view and aren't getting carried along for the ride when you move the view to a new parent.



来源:https://stackoverflow.com/questions/19329721/moving-content-of-uitableviewcell-on-tap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!