moqod / ios-scratch-n-see

The project provides en effect when the user swipes the finger over one texture and by swiping reveals the texture underneath it. The effect can be applied for scratch-card action or wiping a misted glass.
421 stars 104 forks source link

Not working with iOS 9 and iOS 9.1. Tested on iPhone 6s #14

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hello,

When you scratch and image for the first time it works perfect, but if you release your finger and try to scratch the same image again the app freeze. Im trying to solve the problem by myself but not a single error is shown in Xcode. The example project is failing too. Do you guys still work in this project? Can you please help me solving this? or can you tell me how to solve this?

ghost commented 8 years ago

Hi guys. @cyberbum @akopanev @Jnis Can you please help me with this?

ghost commented 8 years ago

I finally found that MDScratchImageView.fillTileWithTwoPoints:(CGPoint)begin end:(CGPoint)end has an infinite loop at while( i.x <= end.x && i.y <= end.y)

It is getting negative values, so I changed to while(i.x > 0 && i.y > 0 && i.x <= end.x && i.y <= end.y)

Now is working but I do not if it is correct.

devdc commented 8 years ago

@enrasoft Hey, hows it going for you with this patch? 1) Have you managed to get it working for iPhone 6s? 2) Have you tested it for other iPhones? 3) Are you using a device? It works just fine with the simulator so it's probably something wrong with iPhone 6s.

devdc commented 8 years ago

So far i've tested it on both iPhone 5s and iPhone 6s both with iOS 9.1 and it works perfectly with adding the patch i.x > 0 && i.y > 0. If I understand it correctly, the issue occurs because of the preciseness of the iPhone 6s screen which can and often allows this to happen: begin: (128.925620, 209.504132), end (128.925620, 209.504132) begin.x eq end.x and same for y so the while condition won't be satisfied thus i.x and i.y are decremented until memory error occurs. So this can be solved by either adding the suggested condition by @enrasoft or by removing the equality condition on (i.x <= end.x && i.y <= end.y) changing it to (i.x < end.x && i.y < end.y).

Cheers

ghost commented 8 years ago

That's it, your solution is cleaner than mine. @devdc

devdc commented 8 years ago

@enrasoft thanks

akopanev commented 8 years ago

hey guys, issue fixed

devdc commented 8 years ago

@akopanev Hey, can you explain your solution please? why (i.x < end.x && i.y < end.y) won't work? thanks

Jnis commented 8 years ago

@devdc , thanks for your help and support.

Hey, can you explain your solution please? why (i.x < end.x && i.y < end.y) won't work?

Target: we need mark all tiles between Begin and End points.

ex.: begin(200,200) end(100,100)

in this case: CGPoint i = begin; while(i.x < end.x && i.y < end.y){ //not reachable code ... }

So "(i.x < end.x && i.y < end.y)" does not work for fast gestures with direction to left/top

devdc commented 8 years ago

@Jnis Thanks! :)