iOS视图控制器两阶段旋转动画崩溃

发布于 2024-12-19 20:26:44 字数 2458 浏览 2 评论 0原文

我面临着一个让我发疯的问题。我阅读了相关内容,但没有找到解决方案。我正在开发一个应用程序,它根据设备方向以模态方式呈现视图控制器。当设备方向朝上时,TabBarController 将以模态方式呈现。 TabBarController 包含两个视图控制器,一个用于显示地图,另一个(尚未实现)用于其他目的。当我更改设备方向时,应用程序冻结并显示以下消息:

MobileAR[8642:707] 使用两阶段旋转动画。要使用 更流畅的单阶段动画,此应用程序必须删除 两阶段方法实现。

2011-12-07 21:47:37.566 MobileAR[8642:707] 使用两阶段旋转 旋转多个视图控制器时不支持动画 或者视图控制器不是窗口委托出现的问题 是当地图视图控制器的 loadView: 方法

控制器的模式表示没有问题时,只要 mapviewcontroller loadView: 执行其他操作,一切都会正常工作。为了更好地理解,下面是代码:

如果 loadView: 是这样的:

- (void)loadView{

    UIView *faceUpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 718)];
    self.view = faceUpView;
    [faceUpView release];
    MKMapView *mkMap = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 1024, 718)]; 
    mkMap.mapType = MKMapTypeStandard;
    [self.view addSubview:mkMap];
    [mkMap release];
}

不会产生任何问题,视图,从而地图在 TabBarController 中正确可视化。

相反,如果在 loadView: 中,我初始化一个这样的视图:

- (void)loadView{

    //Initialize the MapView
    MapView *mv = [[MapView alloc] initWithFrame:CGRectMake(0, 0, 1024, 718)];
    mv.mapViewController = self;
    self.mMapView = mv;

    //Release of the local variable
    [mv release];    
} 

一旦我将设备“面朝上”,它就会冻结,即使我只留下第一行:MapView *mv = [[MapView alloc] initWithFrame:CGRectMake(0, 0, 1024, 718)];

这里是它的初始化器的实现,MapView.m

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.layer.borderWidth = 2; //Set the border of the box
        //State that the subviews are confined within its bounds
        self.clipsToBounds = YES;
        //Initialize the View that contains the map with position and size
       // MKMapView *mv = [[MKMapView alloc] initWithFrame:CGRectMake(-106, -106, BOX_SIDE, BOX_SIDE)]; 
        MKMapView *mv = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, BOX_WIDTH, BOX_HEIGHT)]; 
        //Set the map as standard map (Not satellite nor Hybrid)
        mv.mapType = MKMapTypeStandard;
        //Retains the map
        self.mapView = mv;
        //Add the map to the super view
        [self addSubview:mv];
        //Release the map view previously allocated
        [mv release];

    }
    return self;
}

我没有 ovverride 任何两阶段轮换方法既不是我在一些答案中读到的单阶段方法。

我真的很感谢任何帮助! 谢谢

I'm facing a problem that is driving me crazy. I read about it around but I didn't find a solution. I'm developing an application that presents modally the view controllers depending on the device orientation. When the device orientation is face up a TabBarController is presented modally. The TabBarController contains two viewControllers one to show a map and the other one (not yet implemented) is for other purposes. When I change the device orientation the application freezes showing the following messages:

MobileAR[8642:707] Using two-stage rotation animation. To use the
smoother single-stage animation, this application must remove
two-stage method implementations.

2011-12-07 21:47:37.566 MobileAR[8642:707] Using two-stage rotation
animation is not supported when rotating more than one view controller
or view controllers not the window delegate The problem that occurs
is that when the loadView: method of the map view controller

There are no problems with the modal presentation of the controller everything works fine as long as the mapviewcontroller loadView: do something else. Here is the code in order to have a better understanding:

If the loadView: is in this way:

- (void)loadView{

    UIView *faceUpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 718)];
    self.view = faceUpView;
    [faceUpView release];
    MKMapView *mkMap = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 1024, 718)]; 
    mkMap.mapType = MKMapTypeStandard;
    [self.view addSubview:mkMap];
    [mkMap release];
}

doesn't generate any problems, the view, thereby the map is properly visualized within the TabBarController.

Instead if in the loadView: I initialize a view like this:

- (void)loadView{

    //Initialize the MapView
    MapView *mv = [[MapView alloc] initWithFrame:CGRectMake(0, 0, 1024, 718)];
    mv.mapViewController = self;
    self.mMapView = mv;

    //Release of the local variable
    [mv release];    
} 

it freezes as soon as I put the device "Face Up",even if I leave just the first line: MapView *mv = [[MapView alloc] initWithFrame:CGRectMake(0, 0, 1024, 718)];

Here the implementation of its initializer, MapView.m

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.layer.borderWidth = 2; //Set the border of the box
        //State that the subviews are confined within its bounds
        self.clipsToBounds = YES;
        //Initialize the View that contains the map with position and size
       // MKMapView *mv = [[MKMapView alloc] initWithFrame:CGRectMake(-106, -106, BOX_SIDE, BOX_SIDE)]; 
        MKMapView *mv = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, BOX_WIDTH, BOX_HEIGHT)]; 
        //Set the map as standard map (Not satellite nor Hybrid)
        mv.mapType = MKMapTypeStandard;
        //Retains the map
        self.mapView = mv;
        //Add the map to the super view
        [self addSubview:mv];
        //Release the map view previously allocated
        [mv release];

    }
    return self;
}

I didn't ovverride any of the two-stages rotation method neither the one-stage as I read in some answers.

I really appreciate any help!!!!
Thank you

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文