sách gpt4 ai đã đi

iphone - iPhone lật

In lại 作者:行者123 更新时间:2023-12-03 18:23:13 28 4
mua khóa gpt4 Nike

请考虑下面的代码,并告诉我我做错了什么。

我想在两个 UIView 之间切换。

不知何故,当我从初始 View 翻转时,我只是得到翻转的 View ,没有动画。当我向后翻转时,动画显示得很好。

翻转是由 View 本身上的按钮触发的。

- (IBAction)showMoreInfo:(id)sender
{
UIView *moreInfo = self.flipView;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationBeginsFromCurrentState:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

UIView *parent = self.view.superview;
[self.view removeFromSuperview];

[parent addSubview:moreInfo];

[UIView commitAnimations];

}



- (IBAction)showLessInfo:(id)sender
{
UIView *lessInfo = self.view;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationBeginsFromCurrentState:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.flipView cache:YES];

UIView *parent = self.flipView.superview;
[self.flipView removeFromSuperview];

[parent addSubview:lessInfo];

[UIView commitAnimations];

}

1 Câu trả lời

这可能是因为您没有使用容器 View 作为过渡 View 。请参阅 setAnimationTransition:forView:cache: 上的文档

If you want to change the appearance of a view during a transition—for example, flip from one view to another—then use a container view, an instance of UIView, as follows:

  1. Begin an animation block.
  2. Set the transition on the container view.
  3. Remove the subview from the container view.
  4. Add the new subview to the container view.
  5. Commit the animation block.

尝试在 showMoreInfo: 的动画转换 View 中使用 self.view.superview

showLessInfo: 方法起作用的原因是您正在使用容器 View 。

关于iphone - 翻转 View iPhone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/843534/

28 4 0
Bài viết được đề xuất: iphone - 我们可以使用 iPhone 的 youtube api 仅播放音频吗
Bài viết được đề xuất: iphone - 立即卡住 AVCaptureSession
Bài viết được đề xuất: iphone - 如何删除节的最后一行?
Bài viết được đề xuất: iphone - UISegmentedControl 委托(delegate)/触摸事件
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com