开发者

Modal view being displaced

I have the following code to show a modal view which is added as a subview of my tabBarController. However despite using the autoresizingMask property to allow for when an incoming cellular call interrupts my app and shows the green status bar at the top, i find after this event the whole view is displaced by 20 pixels downwards

    - (void) showLogin:(UIView*) modalView
   {
     CGPoint middleCenter = CGPointMake(160, 226);
     CGSize offSize = [UIScreen mainScreen].bounds.size;
     CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, -210); // start from top
     modalView.center = offScreenCenter; // we start off-screen
         modalView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    [self.tabBarController.view addSubview:modalView];

    // Show it with a transition effect
    [UIView beginAnimation开发者_运维问答s:nil context:nil];
    [UIView setAnimationDuration:0.4]; // animation duration in seconds
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    modalView.center = middleCenter;
    [UIView commitAnimations];
   } 

How to solve this? Thanks


Isn't this a simulator vs. device issue?

On the simulator, the bar simply appears. But that's never going to happen on a real device.

You're never going to just get a green bar on the top of a real device. Instead, your app will go away. When your app "returns," the view will be entirely rebuilt.


Why don't you just present a modal view controller on top of the bar bar?

Of course, you'd have to wrap your modalView into a view controller, but that should not be a problem.

[self.tabBarController.view presentModalViewController: ... animated: YES];


You can override -(void)layoutSubviews in self.tabBarController.view, check the new bounds of that view, and reposition the login view by hand as the bounds change.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜