Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin resize mask not working properly #82

Open
silvermana opened this issue Mar 27, 2012 · 4 comments · May be fixed by #99

Comments

@silvermana
Copy link

The floorf() call causes the view to slowly drift away from where it should be if you resize the superview over and over. Removing the floorf() call solves the problem for me.

else if (hasAutoresizingFor(UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin)) {
            frame.origin.x = frame.origin.x + (delta.width / 2.f); //floorf(frame.origin.x + (delta.width / 2.f));
        }
@davisml
Copy link

davisml commented Apr 18, 2012

Not sure if removing the floorf() is a great solution, as it will cause views to be rendered on half pixels.

@silvermana
Copy link
Author

Rendering on half pixels isn't possible? Fairly sure you want to keep the precision in your views' frames. It's working fine for me.

@blitzvb
Copy link

blitzvb commented Jun 29, 2012

it's possible, but it will be slower.

@michaelmelanson
Copy link

I'm encountering this issue as well.

I think the best solution would be to rework the autoresizing logic in UIView.m to always base the autoresized frame (& bounds?) on an internal "original frame" CGRect rather than self.frame. That original frame would be set to the last frame set by an outside caller (i.e, not the autoresizing logic) by a call to -setFrame:, and the autoresizing logic would pretend the superview resized from the original frame to the new frame in one step. This would prevent the rounding error from accumulating, and fix the 'drifting' problem @silvermana and I noticed.

I tried hacking up that solution but couldn't get it to work. :( Maybe someone else wants to take a stab at it?

In the meantime, removing the floorf function from that line, as @silvermana suggested, fixed the immediate problem so I'm going to go with that for the time being.

@michaelmelanson michaelmelanson linked a pull request Sep 10, 2013 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants