rnystrom / RNBlurModalView

Add depth to your alerts.
MIT License
830 stars 143 forks source link

RNBlurModalView is not center aligned when in landscape. #8

Closed cyndibaby905 closed 11 years ago

cyndibaby905 commented 11 years ago

Tested it in iOS 6 and iOS 5, the RNBlurModalView is not center aligned when in landscape. iOS Simulator Screen shot Feb 15 2013 9 52 58 PM

rnystrom commented 11 years ago

Did you start in portrait and reorient or start in landscape?

cyndibaby905 commented 11 years ago

@rnystrom Yes, I started in portrait and reorient to landscpe. Then I opened the RNBlurModalView but it's not center aligned.

I debugged the code, the root cause of this issue is - [UIView frame] hasn't been updated when performing the method - [RNBlurModalView delayedShow]. When constructing the RNBlurModalView object, its frame depends on its parentView's frame. However, we didn't add it to its parentView immediately but deferred a moment then did an animation to add. At that moment, the frame of parentView may changed, that's why the BNBlurModalView didn't get center aligned.

My solution is whenever BNBlurModalView being added to a parentView, the code will update its frame according to parentView's frame, then perform the rest logic.

Or to better arrange the logic, my suggestion is when constructing the RNBlurModalView, we add it to its parentView immediately but set its property isHidden to YES, then defer a moment to do the animation. The frame of RNBlurModalView will automatically update according to its autoresizingMask, so it's safer.

I just committed my code to fix this issue and opened a pull request, it's in #9 , you could take a look, thanks!

rnystrom commented 11 years ago

Hopefully fixed with your Pull Request. Thanks for that!

https://github.com/rnystrom/RNBlurModalView/pull/9