Sharad D
Sharad D

Reputation: 329

UITableviewcell cropped when tableview is moved

I am creating a UITableview and apply transformation -M_PI_2 so that the tableview scrolls horizontally.

Each cell is also rotated by M_PI_2 for correct display in the horizontal mode. The cells are perfect when I initialize it with a data. Everything works fine.

Now I resize the tableview height to 75% of original and move it down my 25%, top half of cells are hidden(I have set clipstobounds on tableview). I resize the frame of the uitableview using the function setFrame:

This doesn't change even after [tableview reload].

Since the parent(tableview) is moved and resized, shouldn't the child(cells) be moved relative to that?

If not, what is the right way to do the following:

  1. Populate a uitableview and tranform for horizontal scrolling
  2. Resize the frame based on user input
  3. The cells should also align themselves with respect to the new frame of the uitableview.

Upvotes: 1

Views: 270

Answers (1)

wattson12
wattson12

Reputation: 11174

When you apply a transform like this, you are rotating the layer, and so you need to understand the differences between CALayer geometry and UIView geometry

Apples Layer Geometry documentation describes this well but basically I think you will need to adjust the anchorPoint value of your views layer

self.viewToRotate.layer.anchorPoint = CGPointMake(0.0f, 0.0f); //not sure of the actual value here

Upvotes: 1

Related Questions