MKMapView 动画期间的神秘边框

发布于 2024-09-25 10:29:30 字数 1237 浏览 0 评论 0原文

我有一个 UIView,可以在 UITableView 和 MKMapView 之间切换。 MKMapView 在运行时创建,并在以下函数中进行动画处理:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:(self.mapView == nil ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft)
                       forView:self.topView cache:YES];
// create new map view if necc.
if (self.mapView == nil)
{
    self.mapView = [[VTMapView alloc] initWithFrame:self.topView.bounds];
    mapView.mapType = MKMapTypeStandard;
    mapView.delegate = self;
    mapView.scrollEnabled = YES;
    mapView.zoomEnabled = YES;
    mapView.showsUserLocation = YES;
    }
// map visible? show or hide it
if (![self isMapVisible])
{
    tableView.hidden = YES;
    [self.topView insertSubview:mapView aboveSubview:self.tableView];
    mapLoadCount = 0;
} else {
    tableView.hidden = NO;
    [mapView removeFromSuperview];
}
[UIView commitAnimations];

第一次运行正常,但在以后的运行中,动画期间地图视图的顶部和底部会出现水平条。它看起来像这样:

alt text

我尝试过使用缓存设置,删除其他视图等。它不在模拟器中不会发生,但会在 OS 4.1.x 和 3.1.x 上发生。

如果我不隐藏 tableView,我会看到表格的一些部分而不是灰色条,因此我认为在翻转过程中地图视图的大小调整不正确。

I have a UIView in which I flip between a UITableView and a MKMapView. The MKMapView is created at runtime and animated in the following function:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:(self.mapView == nil ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft)
                       forView:self.topView cache:YES];
// create new map view if necc.
if (self.mapView == nil)
{
    self.mapView = [[VTMapView alloc] initWithFrame:self.topView.bounds];
    mapView.mapType = MKMapTypeStandard;
    mapView.delegate = self;
    mapView.scrollEnabled = YES;
    mapView.zoomEnabled = YES;
    mapView.showsUserLocation = YES;
    }
// map visible? show or hide it
if (![self isMapVisible])
{
    tableView.hidden = YES;
    [self.topView insertSubview:mapView aboveSubview:self.tableView];
    mapLoadCount = 0;
} else {
    tableView.hidden = NO;
    [mapView removeFromSuperview];
}
[UIView commitAnimations];

The first time it works fine, but in future runs there are horizontal bars on the top and bottom of the map view during the animation. It looks something like this:

alt text

I've tried playing with the cache setting, removing other views, etc. It doesn't happen in the simulator but it happens on OS 4.1.x and 3.1.x.

If I don't hide the tableView, I see bits of the table instead of the grey bars, so I think the mapview is being resized incorrectly during the flip.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷雾森÷林ヴ 2024-10-02 10:29:30

更改此行:

UIView setAnimationTransition:(self.mapView == nil ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft)
                   forView:self.topView cache:YES];

更改为此行:

UIView setAnimationTransition:(self.mapView == nil ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft)
                   forView:self.topView cache:NO];

这就是答案。

Change this line:

UIView setAnimationTransition:(self.mapView == nil ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft)
                   forView:self.topView cache:YES];

To this line:

UIView setAnimationTransition:(self.mapView == nil ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft)
                   forView:self.topView cache:NO];

And that is the answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文