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

AutoLayout / XIB #9

Closed
cemkozinoglu opened this issue Dec 2, 2014 · 27 comments
Closed

AutoLayout / XIB #9

cemkozinoglu opened this issue Dec 2, 2014 · 27 comments

Comments

@cemkozinoglu
Copy link

Hey awesome piece of code! Problem... When you load a card from XIB.. and move it around stuff within the card does not stay within the bounds.. hard to explain but let me send a screen show.

@cemkozinoglu
Copy link
Author

screen shot 2014-12-02 at 6 30 50 pm

@zhxnlai
Copy link
Owner

zhxnlai commented Dec 2, 2014

Are you using autolayout?

@cemkozinoglu
Copy link
Author

Yup

@zhxnlai
Copy link
Owner

zhxnlai commented Dec 3, 2014

Would this post solve your problem?

http://stackoverflow.com/questions/19917420/autolayout-violates-translation-rotation-animation

@cemkozinoglu
Copy link
Author

It would but I think I found another problem. I read another autolayout/transform suggestion which was;

Wrap everything in the view inside a new host/proxy container view.. And have the container view to set constraints.. What turned out doing that so is.. When i start dragging the Card the frame of the card gets bigger.. Thus the center changes and everything inside the card moved off the bounds.. It wasnt visible before.

I can send a screenshot so you can see what I mean.

Sent from my iPhone

On Dec 2, 2014, at 8:08 PM, Zhixuan Lai notifications@github.com wrote:

Would this post solve your problem?

http://stackoverflow.com/questions/19917420/autolayout-violates-translation-rotation-animation


Reply to this email directly or view it on GitHub.

@zhxnlai
Copy link
Owner

zhxnlai commented Dec 3, 2014

Yes please.

@cemkozinoglu
Copy link
Author

screen shot 2014-12-02 at 9 32 43 pm
screen shot 2014-12-02 at 9 32 12 pm
screen shot 2014-12-02 at 9 31 47 pm

@cemkozinoglu
Copy link
Author

Ignore the "Invite friends" button please.. that is on a higer index on the main-view not on the card-view.

So as you can see, when I have a structure like:

ViewController
|--------ZLSwipeableView
|------------------------- CardView (UIView)
|-------------- Proxy UIView (which constraints to cardView 0,0,0,0)
|-------------- Rest of the buttons/images etc...

Instead of;

ViewController
|--------ZLSwipeableView
|------------------------- CardView (UIView)
|-------------- Rest of the buttons/images etc...

I can observe that when I move the card around, card starts getting bigger. This could be Bounds vs Frame issue when you are doing your magic?

@zhxnlai
Copy link
Owner

zhxnlai commented Dec 3, 2014

My guess is that the frame gets bigger after rotation and the view constraints update subviews based on the rotated frame, causing unwanted behaviors. Sorry, I don't have a solution yet but I will keep an eye on it.

zlswipeableviewissue

@cemkozinoglu
Copy link
Author

http://stackoverflow.com/questions/5361369/uiview-frame-bounds-and-center

Are you using Bounds or Frame doing the calculations? I think it might be to do with Frame vs Bound issue. check the thread out.

@cemkozinoglu
Copy link
Author

3jcne

@zhxnlai
Copy link
Owner

zhxnlai commented Dec 3, 2014

I am using bounds inside ZLSwipeableView. The problem might be that Autolayout uses frame instead of bounds.

@cemkozinoglu
Copy link
Author

Solved it.. here is the trick after adding the proxy view I mentioned above:

  • (void)swipeableView:(ZLSwipeableView *)swipeableView didStartSwipingView:(UIView *)view atLocation:(CGPoint)location {
    UIView *card = view.subviews[0];
    card.translatesAutoresizingMaskIntoConstraints = YES;

    NSLog(@"did start swiping at location: x %f, y %f", location.x, location.y);
    }

So pretty much disabling autolayout when view starts moving.

@zhxnlai
Copy link
Owner

zhxnlai commented Dec 3, 2014

Nice, I'm glad that you solved the problem!

On Wednesday, December 3, 2014, Cem Kozinoglu notifications@github.com
wrote:

Solved it.. here is the trick after adding the proxy view I mentioned

above:

(void)swipeableView:(ZLSwipeableView *)swipeableView
didStartSwipingView:(UIView *)view atLocation:(CGPoint)location {
UIView *card = view.subviews[0];
card.translatesAutoresizingMaskIntoConstraints = YES;

NSLog(@"did start swiping at location: x %f, y %f", location.x,
location.y);
}



Reply to this email directly or view it on GitHub
#9 (comment)
.

@zhxnlai zhxnlai closed this as completed Dec 3, 2014
@dzenbot
Copy link

dzenbot commented Dec 19, 2014

Great advice! thanks for this, it was driving me crazy!
I implemented a contentView, and didn't need to set translatesAutoresizingMaskIntoConstraints to YES in the delegate or elsewhere. Initializing it with the parent view's bounds was enough for me.

Thanks again! Great lib.

@antranapp
Copy link

@cemkozinoglu : Can you show me the code how you load the view from xib. I try to do the same thing but have problem while dragging, the image view is not bounded inside the card view (see screenshot)

screen shot 2015-01-02 at 11 33 07

Here are my contraints for my cardview.xib
screen shot 2015-01-02 at 11 34 41

@zhxnlai
Copy link
Owner

zhxnlai commented Jan 4, 2015

@peacemoon I just updated the demo app. It now includes an example that loads views from xib.

@antranapp
Copy link

@zhxnlai great, thank you

@yingmu52
Copy link

there are some constrain conflicts, any ideas ?

screen shot 2015-01-19 at 00 07 40

@zhxnlai
Copy link
Owner

zhxnlai commented Jan 19, 2015

@yingmu52 Thanks for reporting this issue! I just fixed it so please try the latest version of the demo app.

@yingmu52
Copy link

screen shot 2015-01-21 at 15 14 21

thanks for updating the library.. unfortunately, I still get some warnings.

@zhxnlai
Copy link
Owner

zhxnlai commented Jan 23, 2015

@yingmu52 are you using iOS 8? I double checked and did not get any warning

@yingmu52
Copy link

screen shot 2015-01-23 at 12 25 30
screen shot 2015-01-23 at 12 25 42
screen shot 2015-01-23 at 12 26 56

I am running 7.1.2 on my device. .

@zhxnlai
Copy link
Owner

zhxnlai commented Jan 23, 2015

@yingmu52 That's weird, I tested it on both iOS 7 and iOS8 simulator and it worked fine

@yingmu52
Copy link

https://www.dropbox.com/sh/6r5leuws1p59lyj/AAATZbxFUSXAhABic3HqTdVoa?dl=0

I have put my custom view under this link, it will be great if you could test it for me. thank you :)

@zhxnlai zhxnlai mentioned this issue Feb 27, 2015
@horseshoe7
Copy link

I have an issue where the swipeable view's frame is changed by auto-layout. but the card views have been pinned at the size before the swipeableview frame changed. Anyone know what I need to do?

@ArthurChi
Copy link

there are some problems while I use this with autolayout in iOS7

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

No branches or pull requests

7 participants