touchesBegan only fired within 768x768 pixel rectangle - ios

I'm seeing weird behaviour with my iPad app on both simulator (5.1 and 6.0) and my device (iPad2 running iOS6.0). Whichever orientation the app starts in, touchesBegan is only fired for new touches in the region (0,0) - (767,767) - in portrait mode the bottom of the screen doesn't respond, in landscape the right side.
However, touchesMoved & touchesEnded work on the whole display - if I touch and drag to the 'broken' region, the touch release event is received.
I further noted that while on the iOS 6 simulator my app looks right even though it doesn't work right, on the iOS 5.1 simulator the rendering was also a bit messed up initially too:
The whole display should be grey and that box with sliders in the bottom-right corner. Again, 768 seems the magic value here. Rotating a couple of times fixes this render issue but not the input issue... start in portrait mode and rotate 180 degrees and it now looks right but the top stops responding rather than the bottom.
There is a 3rd-partly library being used here, so my main question is what might cause this kind of problem, what should be I be looking for? I'm also curious as to why the two simulators give different results

If you're touchesBegan, touchesMoved, and touchesEnded all are looking for a location within your self.view, then you might not be in the correct frame area for the touches to be received. I just had a similar problem and I explicitly changed the size of the frame using:
self.view.frame = CGRectMake(0,0,1024,1536);
since my game is two screens tall. After readjusting the frame size, touchesBegan was working fine. Hopefully this helps!

Related

Swift / React Native How to know split view / slide over app's position relative to the whole screen?

I'm making a react-native based app, and I can partially use Swift code by react-native's NativeModule feature.
My app will be used as Split view / Slide over mode in iPad, and I want to know if my app is in the left-side, right-side, or Slide-over.
I could get width and height, also origin (CGPoint) by this code.
let window = UIApplication.shared.windows.first
// Then getting X, Y like this...
window.frame.origin.x
Now my app has only one webview, made by react-native-webview.
So I guess, since the webview is the whole content of the app, and it fills app 100%, so it always returns app.
I want to know, not in webView's perspective, but in app's perpective, the POSITION relative to the screen.
For example, if my iPad width is 1400, and if my app is on the half right side, x should be 700.
And if it is on left side, it should be 0.
I really struggled this, but couldn't find any solution.
FYI, I drawed a diagram for this question.
As I wrote on the above, I tried UIApplication.shared.windows.first.frame.
But it only show the CGPoint of webview, not app relative to the screen.
There is no API for getting 'X' or 'LEFT' in react-native-dimension too.
onLayout also not helpful.

ARKit - Extend the reach of "hitTest"

I want to perform a hit testing from a point on the screen to a Cube in a 3D world. I've been using hitTest from ARKit. It works when I'm standing close to the cube, but when I start moving backwards, it stops working. I'm assuming this is because it's locked to the camera's zRange.
I've tried to set the clipToZRange option to false, like so:
let hits = self.sceneView.hitTest(loc, options: [SCNHitTestOption.clipToZRange: false])`
but it doesn't seem to have any effect.
Am I not setting the option right, or is this a bug?
I am using the latest Xcode and iOS betas.
Turns out the showFeaturePoints debug option from ARKit interferes with hitTest...

Customize UIButton to make compatible to iPhone 5

I am working on my app to customize button accordingly. However once I change my button accordingly, now it has became irresponsive. You could see my code as follows. By the way, this button still works when I run on iPhone 4. It is really strange!
once I change my button position it works, but it wont work the position I want!
float screenSizeHeight=[UIScreen mainScreen].bounds.size.height;
if(screenSizeHeight==568)
[positionButton setFrame:CGRectMake(184,280,77,30)];
if(screenSizeHeight==480)
[positionButton setFrame:CGRectMake(184,240,77,30)];
Hand Bag button is not working!
Check your condition :
if(screenSizeHeight==568)
In both cases you have used screenSizeHeight == 568 so replace one with screenSizeHeight = 480
Hope it helps you.
Check your Default-568h.png image get added or not. If it isn't added , you mainscreen returns bounds as 320x480.
Note : 1) If you rotate device , check your main screen bounds. It may lead to confusion. You can try Better way to use it.
2) This Default-568h.png is only allowed when building an app using Xcode 4.5 and the iOS 6 SDK
3) When you ask a UIScreen for it's Bounds you get the bounds of the screen, which is the whole device screen. (the status bar is part of the screen)

iOS5: UIScrollView dispaying and scrolling differently from iOS4

This is a curious one.
I have an IBOutlet UIScrollView playScrollView whose height is exactly 1/3 of it's contentSize's height. The app is in landscape. I call this code...
[playScrollView scrollRectToVisible:CGRectMake(0.0f, page * PLAY_VIEW_PAGE_HEIGHT,
480.0, PLAY_VIEW_PAGE_HEIGHT)
animated:animated];
... (the int page ranges from 0 to 2) to start on page 1 (displaying the middle third) then go up or down as needed when the user presses buttons.
This works fine for iOS4 both device and simulator, and has been live on the app store for months with no problems. Even iOS5 devices are fine with existing builds, it was only when the app was recompiled for iOS5 that it stopped working correctly on iOS5 devices.
Since updating to XCode 4.2, This doesn't work for iOS5. It goes one page too low, showing the bottom page when it should show the middle. I can get the code to work for iOS5 (device and simulator) by changing page to (page-1)...
[playScrollView scrollRectToVisible:CGRectMake(0.0f, (page-1) * PLAY_VIEW_PAGE_HEIGHT,
480.0, PLAY_VIEW_PAGE_HEIGHT)
animated:animated];
...but of course this breaks iOS4, which works fine with the old code, but gets stuck one page too high with this new code. iOS4 and iOS5 are exactly PLAY_VIEW_PAGE_HEIGHT out-of-step (288 pixels, a third of the height of playScrollView). The same thing happens if I use setContentOffset: instead.
One other curious thing, probably the key to this. If I don't do the scrollRectToVisible at all, then iOS4 sits at the top of playScrollView, wheras iOS5 shows the middle third, (ie PLAY_VIEW_PAGE_HEIGHT pixels down).
I could detect the iOS and use different code for each, but that's a horrible kludge. If it's an iOS5 bug and they fix it in a future release, that would break the live app.
Has anyone any ideas, or noticed anything similar? Thanks.

presentationLayer position property yielding bad values on iPad, no problem with iPhone

I have a game with several small objects animated using CAKeyframeAnimation. Objects animate perfectly for BOTH iPhone and iPad. However, the value of the position property of the animated CALayers' presentationLayers only yield reasonable values on the iPhone. I use the current position of the animating objects for hit testing. Any ideas of differences in this area between iPad and iPhone/iPod Touch?
The position points for iPhone show expected incremental change as objects animate; on iPad I see peculiar values, for example this sequence:
<-36893488147419103232.000000,2.607987>,
<-0.000000,2.658927>,
<0.000000,2.709929>,
<36893488147419103232.000000,2.755450>, ...
Other properties of the presentationLayer are correct (these are properties whose values don't change during the animation, however).
After the animation finishes, the presentationLayer position value IS accurate.
Exactly same problem here!! and it looks that is a bug starting with 3.2 version of the SDK...
Actually I did a iPhone app (using 3.1 SDK) that it is completely based on CAAnimation, when I installed and ran the the app on an iPhone with 3.2 nothing works!!!... but on devices that has 3.1 works perfectly. I google it and I found another people with exactly the same problem.
take a look at the bottom of the following forum
http://www.iphonedevsdk.com/forum/iphone-sdk-development/19622-current-position-animating-calayer.html
Could you solved this issue or found a workaround?

Resources