I'm creating a bunch of UIViews and immediately adding them to an array which is constantly looped through to animate the views. All the views are created with a frame where frame.origin.y = -45. But on occasion they get placed with a y of 0. I can't figure out for the life of me why that is.
1)I override setFrame in my ViewController and added an NSLog to that to make sure it's not getting called from some unexpected location. This gets called as soon as I create the view and set the frame. It outputs the correct y value of -45.
2) Then I set the frame of the object I trace out the frame and it is also correct:
..and that outputs say:
176.000000 -45.000000
176.000000 -45.000000
That's what I wanted!
3) But in the animation loop when I output the y value I get 0.00:
Is there something I can call to make sure that the view gets drawn to the correct place? It looks like the default for a frame.origin.y value is 0, so I'm assuming this just isn't getting updated quickly enough or something. I set the following in the view but it didn't help:
[self setContentMode:UIViewContentModeRedraw];
Again, 90% of this time, this works like a charm, but every once in a while a view is created in the wrong location. The biggest problem is that when this happens my hitTest doesn't detect the touch of that view. I'm not exactly sure why that is, but I know that it is a result of the view not created created in the correct place, so the coordinates somehow get off.
Thanks in advance for any ideas, clues, or solutions!
1)I override setFrame in my ViewController and added an NSLog to that to make sure it's not getting called from some unexpected location. This gets called as soon as I create the view and set the frame. It outputs the correct y value of -45.
2) Then I set the frame of the object I trace out the frame and it is also correct:
Code:
[tvc.view setFrame:frame];
NSLog(@"%f %f", tvc.view.frame.origin.x, tvc.view.frame.origin.y);
NSLog(@"%f %f", tvc.view.frame.origin.x, tvc.view.frame.origin.y);
..and that outputs say:
176.000000 -45.000000
176.000000 -45.000000
That's what I wanted!
3) But in the animation loop when I output the y value I get 0.00:
Code:
CGRect frame = [[[tv layer] presentationLayer] frame];
NSLog(@"do step -- %@ %f", tvc.letter, frame.origin.y);
Is there something I can call to make sure that the view gets drawn to the correct place? It looks like the default for a frame.origin.y value is 0, so I'm assuming this just isn't getting updated quickly enough or something. I set the following in the view but it didn't help:
[self setContentMode:UIViewContentModeRedraw];
Again, 90% of this time, this works like a charm, but every once in a while a view is created in the wrong location. The biggest problem is that when this happens my hitTest doesn't detect the touch of that view. I'm not exactly sure why that is, but I know that it is a result of the view not created created in the correct place, so the coordinates somehow get off.
Thanks in advance for any ideas, clues, or solutions!