Comments (71)
Do you mean you don't want to allow the page to turn at a non-straight angle such as 45 degrees? You want to keep the curl straight/vertical?
from xbpagecurl.
Exactly.
from xbpagecurl.
I have pushed a few changes in order to support limiting the angle of the cylinder. You can now use the XBPageCurlView's minimumCylinderAngle and maximumCylinderAngle to limit the angle in an interval. I think M_PI_2 for both will work for you. You should also set the XBPageDragView's cornerSnappingPoint.angle to M_PI_2 in this case. Let me know whether this helps.
from xbpagecurl.
Wow, thanks! I'll give it a try and let you know if it works.
from xbpagecurl.
Any idea why my XBPageDragView doesn't seem to be working?
CGRect r = CGRectZero;
r.size = self.view.bounds.size;
self.curlViewDrag = [[XBPageDragView alloc] initWithFrame:r];
self.curlViewDrag.viewToCurl = webView;
[self.curlViewDrag refreshPageCurlView];
//self.curlViewDrag.cornerSnappingPoint.angle = M_PI_2;
[self.view addSubview:self.curlViewDrag];
Is the init code I'm using...the full source is over here: https://docs.google.com/file/d/0B-sm1N6j2oahSTd6NGIyakptMXc/edit?usp=sharing
(Relevant file is ReadingView.m)
from xbpagecurl.
It isn't rendering anything?
from xbpagecurl.
I suppose it might be, but when I run it nothing happens. I don't get any errors, but nothing else happens. Neither curl nor drag functionality appears. Is it possibly because of my WebView handling touch events (js)?
from xbpagecurl.
The XBPageDragView must be added as a visible subview in your hierarchy, like a button. It must be on top of everything.
from xbpagecurl.
I changed the code thus:
CGRect r = CGRectZero;
r.size = self.view.bounds.size;
self.curlViewDrag = [[XBPageDragView alloc] initWithFrame:r];
self.curlViewDrag.viewToCurl = webView;
self.curlViewDrag.cornerSnappingPoint.angle = M_PI_2;
[self.curlViewDrag refreshPageCurlView];
[self.view addSubview:self.curlViewDrag];
[self.view bringSubviewToFront:self.curlViewDrag];
[self.curlViewDrag refreshPageCurlView];
And it's still not working. It might be worth noting that whenever I created it via Interface Builder, I get EXC_BAD_ERROR. It seems to happen in refreshPageCurlView on this line:
self.pageCurlView = [[XBPageCurlView alloc] initWithFrame:self.viewToCurl.frame];
I only get that error, though, when I create it via Interface Builder. My viewToCurl is on a webview, but it happens even when I set it to other views.
from xbpagecurl.
I'm not using storyboards anymore (although maybe I didn't get rid of them properly?) but it's still not working, even when I removed the refreshPageCurlView from the setter for curlViewDrag, which is where the error was originating. Now, when I tap to drag, I just get black, or white. Like the view was removed or hidden.
from xbpagecurl.
Thanks for all your help. I've managed to fix it: turns out the root of the problem was that I hadn't included everything that was necessary in my build. /facepalm
But now that it's working, I'd love some help with another issue I'm having. I added the snapping point you suggested, and it sort of works: when you drag from the right, it doesn't snap to the bottom, and will allow you to drag fully across the view. Unfortunately, when it's let go mid-drag, it still snaps to reveal the bottom-right area, instead of continuing on across the view.
Also, is there a way to strictly conform the path to side-to-side curling, with no up and down? This is close, but I was wondering. And can a curl start on the left, and move to the right?
Thanks for all the help!
from xbpagecurl.
Sorry for the lack of updates. Are you using the minimum/maximumCylinderAngle as stated above? If you want it to snap to the left so that the page will disappear, you should try placing a snapping point at (0,0) with radius 0 and angle M_PI_2. It snaps to the point that is closest to the cylinder axis so.. it will only snap to this point on the left when it is past the center of the screen. I just had one idea.. the snapping points should have a 'weight' that allows you to control which point should win the battle. For instance, if the left snapping point has a higher weight than the one on the right (the default cornerSnappingPoint), the page will snap to it even before the cylinder axis hits the horizontal center of the screen. Sounds interesting..
from xbpagecurl.
Thanks! That solves part of the problem. It now moves all the way across the screen, but only if the drag has moved at least halfway across the screen :/ If I just start the drag and only move a little ways across the screen, it still snaps to where it shows the bottom-right corner. Also, maximum and minimum cylinder angle don't seem do do anything to only allow right-to-left drag.
Am I missing something?
This is the code I'm using:
self.curlViewDrag.pageCurlView.maximumCylinderAngle = M_PI_2;
self.curlViewDrag.pageCurlView.minimumCylinderAngle = M_PI_2;
self.curlViewDrag.cornerSnappingPoint.angle = M_PI_2;
self.curlViewDrag.cornerSnappingPoint.radius = 0;
self.curlViewDrag.cornerSnappingPoint.position = CGPointMake(0, 0);
[self.curlViewDrag refreshPageCurlView];
from xbpagecurl.
Hey, I have added the weight on the snapping points. Try setting a weight higher than 1 on the snapping point you have on the left. I would try a weight of 2 to start with.
from xbpagecurl.
That worked perfectly! I must say, you are the most active and communicative and helpful developer I've met. Thanks for all the hard work. Any suggestions for maximumCylinderAngle and minimumCylinderAngle? Thanks again!
EDIT:
I also just noticed something...I utilized the addSnappingPoint function you provided in the recent commit, so that it would snap to both sides of the screen - left and right.
- (void) initPageDrag {
float width = self.view.bounds.size.width;
float height = self.view.bounds.size.height;
self.curlViewDrag.viewToCurl = self.view;
//Remember to refreshPageCurlView on rotate,
//and to inhibit rotate mid-drag
self.curlViewDrag.pageCurlView.maximumCylinderAngle = M_PI_2; //doesn't seem to work...
self.curlViewDrag.pageCurlView.minimumCylinderAngle = M_PI_2; //doesn't seem to work...
[self.curlViewDrag.pageCurlView addSnappingPoint:
[[XBSnappingPoint alloc] initWithPosition:CGPointMake(width, height/2) angle: M_PI_2 radius: 0 weight: 2 ]];
self.curlViewDrag.cornerSnappingPoint.angle = M_PI_2;
self.curlViewDrag.cornerSnappingPoint.radius = 0;
self.curlViewDrag.cornerSnappingPoint.weight = 2;
self.curlViewDrag.cornerSnappingPoint.position = CGPointMake(0, height/2);
[self.curlViewDrag refreshPageCurlView];
}
However I noticed that using the above code, when it snaps the the right, a dark overlay appears over the view, but doesn't happen when it snaps the the left. I know i can probably get around this by hiding it or whatever for now, but I was just curious. Also, can drag speed be controlled?
from xbpagecurl.
I also thank you for the ideas which improve the framework. You should set both the maximum and minimum angles to M_PI_2.
from xbpagecurl.
I thought I did...?
self.curlViewDrag.pageCurlView.maximumCylinderAngle = M_PI_2;
self.curlViewDrag.pageCurlView.minimumCylinderAngle = M_PI_2;
//or
[self.curlViewDrag.pageCurlView setMaximumCylinderAngle:M_PI_2];
[self.curlViewDrag.pageCurlView setMinimumCylinderAngle:M_PI_2];
Neither seemed to work...
from xbpagecurl.
What happens instead?
from xbpagecurl.
The rotation remains as flexible as usual.
from xbpagecurl.
Ouch, there was a bug in my code. Please check my last commit.
from xbpagecurl.
That works perfectly. Thanks, again. Question: is there an official way to know when a point has been snapped to, or when the drag is over? I don't see one in the code. For now I just hijacked this code:
[self setCylinderPosition:closestSnappingPoint.position cylinderAngle:angle cylinderRadius:closestSnappingPoint.radius animatedWithDuration:kDuration completion:^{
if ([weakSelf.delegate respondsToSelector:@selector(pageCurlView:didSnapToPoint:)]) {
[weakSelf.delegate pageCurlView:weakSelf didSnapToPoint:closestSnappingPoint];
}
NSLog(@"snap done");
}];
from xbpagecurl.
Just implement the XBPageCurlViewDelegate protocol.
from xbpagecurl.
That's so obvious now that I examine the code...I need something to eat. Thanks.
from xbpagecurl.
Oh, and there's a similar bug with the delegate being reset on refreshPageCurlView...that or I'm doing something wrong.
from xbpagecurl.
I see.. the XBPageDragView needs the delegate as well.. we'll have to use something else there..
from xbpagecurl.
I ditched the delegate in favor of notifications. Now multiple instances can receive the snapping events and other that are still to come.
from xbpagecurl.
Works beautifully!
That gray overlay I told you about when it snaps to the right is quickly becoming the bane of my existence, and hiding PageCurlView is slowing things down a bit too much...any suggestions?
from xbpagecurl.
Actually, nevermind. Doing a refreshPageCurlView when the snap is complete fixes that problem. ;)
from xbpagecurl.
Hmm....Interesting issue I'm getting...
I have an UIImageView, that for most of the application's use is hidden. However, when the user starts a drag, I show the UIImageView (it is the viewToCurl) and then send touches to XBPageDragView. When the drag is over, I hide the UIImageView.
Problem: When the drag starts, I get a fast flicker where first the UIImageView shows, then the XBPageDragView (or pageCurlView) shows, but it's empty of the viewToCurl, then it updates and the pageCurlView is visible inside it and all is right.
I know this might be a niche issue, but if you have any solutions to offer that would be great. From breakpoints, etc., it seems to be coming from code inside XBPageDragView. Thanks - I can post some code if it'd help.
from xbpagecurl.
Show code.
from xbpagecurl.
Here: https://gist.github.com/matt-curtis/5174689
Skip down to the comment where it says "trouble code here". What happening is this: I don't want page curls to always happen over my webview, so I parse touches to be selective. Since there's issues with touch detection on webviews, I have JS pass the coordinates of touches/drags etc, and pass those touches on to the XBPageDragView. It works smoothly, and without any perceivable slow-down...except the slight flicker issue.
from xbpagecurl.
From what I can tell the problem might be related to when everything draws...it seems that the pageCurlView is black, or empty initially...not sure.
from xbpagecurl.
Where do you start/stop the animation? Aren't you using XBPageDragView? With XBPageDragView you can limit the area where the user can drag the page. One possible solution to kill the flicker is to call drawViewInFrontOfPage before swapping the views.
from xbpagecurl.
Hmm. This is interesting. I'm starting to suspect that XBPageDragView might just not like UIImageViews. Even when I don't hide the UIImageView, I still get the bug. The view now also keeps transparent after the first drag, instead of drawing the view on top of itself... I'll have to experiment more, maybe with a non-updating Image view instead of one that updates.
from xbpagecurl.
I haven't come up with a viable solution to this, so far...at least not with how I'm currently doing things. I can't seem to get rid of that flicker. Frustrating.
I should also mention drawViewInFrontOfPage doesn't seem to work (I get an error?), but I might be using it incorrectly.
from xbpagecurl.
Are you referring to the same code above? If not show some code. XBPageCurl simply uses -[CALayer renderInContext:] in order to draw the view in an OpenGL texture and it does not work perfectly in a few situations.
from xbpagecurl.
I'm going to start a fresh project, and see if the same thing happens with a UIImageView, or if it's just my code...
Sent from my iPod
On Mar 24, 2013, at 10:15 AM, xiss burg [email protected] wrote:
Are you referring to the same code above? If not show some code. XBPageCurl simply uses -[CALayer renderInContext:] in order to draw the view in an OpenGL texture and it does not work perfectly in a few situations.
—
Reply to this email directly or view it on GitHub.
from xbpagecurl.
I'm using the code above, still...I think the problem might be somehow related to Clears Graphics Context, which has been known to draw that black transparent rect before rendering. What I don't get is that although I have it unchecked on both XBPageDragView and my UIImageView, I still see it...
And weirder, it didn't do it on my other project.
from xbpagecurl.
Phew, finally made some headway towards figuring this out. The problem seems to be this block of code (sort of my initialization code, sets up the snapping points on both sides of the screen):
float width = self.view.bounds.size.width;
float height = self.view.bounds.size.height;
[self.curlViewDrag.pageCurlView addSnappingPoint:
[[XBSnappingPoint alloc] initWithPosition:CGPointMake(width, 0) angle: M_PI_2 radius: 0 weight: 2 ]];
self.curlViewDrag.cornerSnappingPoint.angle = M_PI_2;
self.curlViewDrag.cornerSnappingPoint.radius = 0;
self.curlViewDrag.cornerSnappingPoint.weight = 2;
self.curlViewDrag.cornerSnappingPoint.position = CGPointMake(0, 0);
Seems like there some sort of issue with changing corner snapping point...whatever the case, the following fixed things:
float width = self.view.bounds.size.width;
float height = self.view.bounds.size.height;
[self.curlViewDrag.pageCurlView addSnappingPoint:
[[XBSnappingPoint alloc] initWithPosition:CGPointMake(width, 0) angle: M_PI_2 radius: 0 weight: 2 ]];
[self.curlViewDrag.pageCurlView addSnappingPoint:
[[XBSnappingPoint alloc] initWithPosition:CGPointMake(0, height/2) angle: M_PI_2 radius: 0 weight: 2 ]];
self.curlViewDrag.cornerSnappingPoint.angle = M_PI_2;
[self.curlViewDrag refreshPageCurlView];
Also, I'd propose a removeAllSnappingPoints function - currently you can only and remove specific ones.
from xbpagecurl.
The problem might be that the page mesh was not properly visible because of the cylinder position, and not because of texture or framebuffer issues. Although it is not very clear why would that happen in your example.
I've added the removeAllSnappingPoints method by the way.
from xbpagecurl.
Thank you.
Occasionally I will get "Failed to create framebuffer: 8cd6" on my drags, followed by multiple lines of "1286". What could I be doing that causes this?
from xbpagecurl.
Actually, I don't think that's related to OpenGL, possibly another part of my code. Disregard it.
Question: XBPageDragView doesn't seem to respond well to very short drags. When using it in this case...:
2013-03-29 21:09:59.138 BookIt[61161:907] dragBegin - Point: {232, 409}
2013-03-29 21:09:59.157 BookIt[61161:907] dragMove - Point: {233, 409}
2013-03-29 21:09:59.195 BookIt[61161:907] dragMove - Point: {224, 409}
2013-03-29 21:09:59.200 BookIt[61161:907] dragEnd - Point: {224, 409}
It never fully registered dragEnd (touchesEnded) and the curl stops where it's at, instead of the snapping point. As far as I can tell, all the code to get the nearest snapping point works fine, it's the [self setCylinderPosition] selector that is apart of the problem. I'm wondering how to avoid this situation.
from xbpagecurl.
Actually...I think I may have fixed my own problem. Working with this has certainly been an experience, I've never felt more like a newbie with something.
from xbpagecurl.
@matt-curtis do you still have any problems?
from xbpagecurl.
Besides the occasional 'can't create framebuffer' issue, no. I lowered how often I see that drastically by changing how often you can curl, but it still happens sometimes. Any tips on avoiding it?
Sent from my iPod
On Apr 1, 2013, at 8:03 AM, xiss burg [email protected] wrote:
@matt-curtis do you still have any problems?
—
Reply to this email directly or view it on GitHub.
from xbpagecurl.
Oh, and I was wondering: why is it that curls get buggy and slow when I run my app without the debugger?
Sent from my iPod
from xbpagecurl.
The "Failed to create frame buffer: .." error happens probably because the size of the view is zero when the createFramebuffer
method is called. You could check it yourself by setting a breakpoint around XBFilteredView.m:963.
The lower frame rate issue is really weird and happens with me if I, for instance, curl the page, push the home button and touch the app icon again.. the frame rate drops a noticeable amount. This is yet to be investigated.
from xbpagecurl.
XBFilteredView?
from xbpagecurl.
yes(?)
from xbpagecurl.
I don't see a file named that. Am I not looking in the right place?
Sent from my iPod
On Apr 7, 2013, at 7:03 PM, xiss burg [email protected] wrote:
yes(?)
—
Reply to this email directly or view it on GitHub.
from xbpagecurl.
Ouch sorry… that is from another project, lol.. it is XBCurlView:371.
from xbpagecurl.
Thanks, I'll check that out. Speaking of the slowdown issue, I noticed that
when I turn off OpenGL Frame Capture in scheme settings, the slowdown issue
occurs, even when I'm debugging. So perhaps it's related to that?
EDIT:
Funny, I created the breakpoint...and now, I can't get the framebuffer issue to show. Odd. I must've done something to the code that was causing it. Either way, good to know in case it happens again.
from xbpagecurl.
If the size of the view is zero...how do I fix that?
from xbpagecurl.
Is that a problem? The frame buffer is recreated after the size of the view changes. The view size is initially zero probably because of auto-layout and whatnot.
from xbpagecurl.
I'm not sure, actually. I'll double check.
from xbpagecurl.
Here's what the error looks like when I get it:
from xbpagecurl.
That is about right, the view size is zero then it will fail to create the framebuffer. Anyway, that is not a problem since it is going to be recreated after the view gets its actual (non-zero) size. You can just ignore that error, which can be actually considered a warning.
from xbpagecurl.
Hmm. I get this error in the log every few curls, and no curl happens when I do:
Usually happens on swipe curls, though.
2013-04-28 21:14:51.807 BookIt[3823:907] Failed to create framebuffer: 8cd6
2013-04-28 21:14:51.824 BookIt[3823:907] 1286
from xbpagecurl.
Well, that is a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error followed by a GL_INVALID_FRAMEBUFFER_OPERATION.. do these errors happen only when the view size is zero? Doesn't the view get a new non-zero size thereafter which also leads to a call to layoutSubviews?
from xbpagecurl.
It appears to happen only when the view size is zero...both viewportHeight and viewportWidth are 0. That's on the "Failed to create framebuffer" break point. How would I test for the other half?
BTW...I call refreshPageCurlView every time a curl is finished. Related?
EDIT...
Ah, that seems to be apart of the problem. Commenting out my call to that fixed it. Oddly enough, lack of it slowed down my app somewhat.
I need the refreshPageCurlView call because otherwise, I get a black, semi-transparent rectangle that flickers.
from xbpagecurl.
Haha! I am triumphant! It turns out all this stems from my stupid implementation of passing drag touches from a UIWebView to the Curl View. I've ironed out the kinks, and it seems almost buttery.
from xbpagecurl.
I'm also still dealing with the issue of when not debugging, curling and the app slows down dramatically. I haven't managed to find the source yet...
from xbpagecurl.
You should profile the app with Instruments (Time Profiler).
from xbpagecurl.
The problem seems to be around here:
I'll muck around and see if I can resolve that...
Also a link to the instruments log file: https://docs.google.com/uc?export=download&id=0B-sm1N6j2oahVXBOVm0zOC1JZjg
from xbpagecurl.
Ha. Turns out, I'm really, really, really bad at OpenGL drawing, and I've actually managed to make the code sooo much worse.
from xbpagecurl.
Hmm. I've been working (not sure if you can call it that) with the OpenGL code, and while I did manage to make 3d rainbows, my iPod crash, and Instruments commit homicide, I also found that
from xbpagecurl.
Do you have any other suggestions? I've had no success on my own with the OpenGL code...I just know it that the slow down only occurs when OpenGL ES Frame Capture is unchecked in Scheme settings. :/ You've been extremely helpful and I appreciate it.
from xbpagecurl.
I've managed to isolate the issue to my calling this block of code when a snap is complete:
[self.curlViewDrag refreshPageCurlView];
[self.curlViewDrag.pageCurlView removeAllSnappingPoints];
[self.curlViewDrag setUserInteractionEnabled:NO];
For whatever reason, it causes issues when done immediately when XBPageCurlViewDidSnapToPointNotification is called. I'm using a timer now and it seems to solve the problem, but, is there a more efficient way of doing this? I'm needing to refresh the curl view because of the black overlay issue I mentioned. I'm assuming that part of this issue is coming from that fact that I'm refreshing the view before the curl is completely done. Is there a way to tell for sure when things are done?
from xbpagecurl.
There was what I think is a bug in the XBPageDragView code that was causing this. I'll update this with my discoveries later.
from xbpagecurl.
Well, this thread has become a mess already :P. I will close it by now and if you have any other more specific issues, please open a new one.
from xbpagecurl.
Agreed...70 comments? What was I doing? Anyway, I guess I should still post my solution. The problem was here:
- (void)pageCurlViewDidSnapToPointNotification:(NSNotification *)notification
{
XBSnappingPoint *snappingPoint = notification.userInfo[kXBSnappingPointKey];
if (snappingPoint == self.cornerSnappingPoint) {
self.hidden = NO;
_pageIsCurled = NO;
self.viewToCurl.hidden = NO;
[self.pageCurlView removeFromSuperview];
[self.pageCurlView stopAnimating];
}
}
It doesn't account for all snapping points (which was an issue, since I was only using the snapping points array).
from xbpagecurl.
Related Issues (20)
- Weird behavior of the example project HOT 3
- tap to uncurl
- Curl -- corner doesn't always pick up HOT 4
- some bug
- XBPageCurl curling acting weird
- another gpus_ReturnNotPermittedKillClient crash HOT 2
- How to implement pages flipping like iBook? HOT 1
- Page Flipping in Two Page Book HOT 1
- Source differences between Git and Cocoapods HOT 1
- duplicate symbol _XBAnimationInterpolatorEaseInOut HOT 3
- updating the frame of the curlView for the next page HOT 2
- Calling drawImageOnNextPage: not working
- Unable to use this library in Swift.
- OpenGL Error 501 in console logs
- EXC_BAD_ACCESS in applicationWillResignActiveNotification
- curl animation don't work very well on IPhone 6 HOT 1
- curl effect render hide and show
- won't compile cleanly. Needed: In XBAnimation.h, the 4 blocks need to be marked extern
- https://github.com/bachelora/iOS-PageCurl-OpenGL
- Unable to integrate this onto the Swift project HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xbpagecurl.