开发者

How Can i animate two UIView reisizes at once?

Im using this code:

开发者_Python百科
   [UIView beginAnimations:nil context:NULL];  
   [UIView setAnimationDelegate:self];
   [UIView setAnimationDidStopSelector:@selector(_shrinkDidEnd:finished:contextInfo:)];
   tblSimpleTable.frame = tableFrame;  
   messegeField.frame = messegeFrame;
   [UIView commitAnimations];

Where messegeFrame and tableFrame are the new frames of this views. I hoped that this would of made the table and the messege field move together, but first the table moves and only then the messege field. Is there anyway of making them move together?

notice: the thing is that both of them are resizing but not in the same time


Try setting a timer on the animation, I have moved dozens of views simultaneously and this is the notable absence in your code:

[UIView beginAnimations:nil context:NULL];  

[UIView setAnimationDuration:0.3];

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(_shrinkDidEnd:finished:contextInfo:)];
tblSimpleTable.frame = tableFrame;  
messegeField.frame = messegeFrame;
[UIView commitAnimations];

I would also not that I have not used the setAnimationDidStopSelector, so if that is your problem you can call the end of the animation with a NSTimer set to the same time length as the animation.


As face value this code looks ok and I have used this method to translate more than 1 object at once before.

IF you are just moving those 2 objects, there are alternatives you could try: UIOBJECT.center - although this indirectly affects the frame. Or overkill with a CGAffineTransformTranslate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜