For the UI Test case I need to "zoom out" in the map view. When using pinch zoom out code it only moves map to the left.
let app = XCUIApplication()
app.maps.element.pinch(withScale: 0.9, velocity: -0.5)
Dose someone knows how to achieve "zoom out" functionality in the UI Testing?
I want to notice that "zoom in" works fine.
The problem is that one finger of the simulated pinch gesture is falling on the status bar, so only the other finger is registered.
You can solve the problem in your example project by adding the following to ViewController.swift:
override var prefersStatusBarHidden: Bool {
return true
}
When zooming out, the UI test system seems to simulate a pinch from the very top left and bottom right of the view, constrained to the edges of the screen. This doesn't seem to take the status bar into account, and so the top-left touch falls on the status bar and is ignored, and only the bottom-right touch is registered by the view, causing the pinch to become instead a drag up and left. This isn't just with maps, it seems to be an issue with all scroll views.
If you do want to display the status bar on top of the view, you may need to figure out another way to constrain your pinch to not fall on the status bar. In my case, I was fine simply removing the status bar.
Related
I have created a game where a map is on the screen. With this map I would like to have buttons to change scenes and preform actions. The map I have on the screen I would like to be the full screen with pinch zoom capability, along with capability of a button or label to be on top of the image, without the button being zoomed in on or below the scroll view. I tried using a UIScroll View but the button kept zooming in and going below the image. How can I set the background of my View to a pinch zoomable image with labels and buttons on top not being effected in swift and xcode 7?
I am not sure if this is the most efficient way, but by calling the method touchesDidBegin() you can move the objects like the TextField and the buttons to a new view that is above the scrollview. Then when touchesDidEnd() you can move them back into the scrollview.
I am creating an iOS app using storyboard to plot some locations in a map. While running it, in the simulator, whatever button(mouse button) I click, the view just zooms in. How can I zoom out. Whether I should place a scroll bar in the view, or is there any other possibilities.
Holding Alt on the keyboard will allow you to make a pinch gesture.
I have a button in an iPad app with frame.origin.x == 0. The user has to be able to move the button with his finger. I realized this with a UIPanGestureRecognizer and it works fine. However I got a bug report, that the button doesn't move if the user moves his finger from outside the screen (from the black margin of the iPad). I checked and the selector of the UIPanGestureRecognizer doesn't get called when the touch enters the button's frame.
Is there any way to fix this? In the iOS main screen it works, so you can scroll the apps even with a gesture started from outside the screen.
I figured it out. I've had a UIView outside the screen that came in with that button and it's right-most corner was at x == 0. If I set that view to hidden when it is outside the screen, the PanRecognizer works.
I am using an MKMapView to create a thumbnail on my screen. However it doesn't render in the position that I set it to on IB. It moves up. It also moves up even further after I go to push and pop a screen over it. Any idea how to position this correctly?
I figured it out. It was related to auto sizing.
also there was toolbar at the bottom after the push/pop.
I am writing an ipad application where you can drag around the screen with 1 or 2 fingers. I use the touchesBegan, touchesMoved and touchesEnded methods to recognize the touches. I have multipletouches enabled for the view.
Now I have recognized one strange behaviour. If I place a finger outside of the upper screen border and drag it down to the screen I won't receive a call to touchesBegan or touchesMoved. This can not be reproduced for the other screen borders.
The only other case where it can be reproduced is when I use landscape orientation with the home button to the left side. In this case I get the same behaviour for the upper screen border.
Has anyone information about this or does experience the same if testing?
Edit:
I did some additional testing. The area where the statusbar would normally be is receiving touchesBegan or touchesMoved very fine if i put down the finger in that region or slide it upwards from any lower screen position. The input is not recognized only if i slide the finger down from a position that is completly above the screen edge.
Edit2:
Additional Info:
- My app uses an OpenGL view.
- The statusbar is hidden.
- touchesBegan is called properly when touching the (hidden) statusbar areas in all orientations.
I believe the underlying issue is that the touch-sensitive layer on the screen extends a few pixels above the visible screen, meaning that touches originating there technically start outside your UIViewController view. Since your UIViewController only sees touches that originate within its view, it won't see these touches. So if your device screen is touched a pixel or two above the visible pixels, the touch will be sent to whatever virtual layer exists in that offscreen area (perhaps the status bar?). This prevents your UIViewController from receiving any touches, since the swipe did not originate in your UIViewController's view area.
To work around this, at applicationDidLaunch time you can resize your UIWindow to be (say) 10 pixels larger on each side, and create an intermediate UIViewController 'background' layer inside it, matching the expanded size of the window. Then set your main interface UIViewController view to be a child of the 'background' view, inset 10 pixels on all sides to re-match the physical screen size. If your interface rotates, the 10-pixel enlargement of the background view will have to be re-applied in the willAnimateRotationToInterfaceOrientation method in your background UIViewController each time.
Finally, have the touchesBegan/Moved/Ended methods in the background view controller forward their touches directly to the corresponding methods in your main UI view controller. Voila!
Hope this helps,
Ben
Sounds right to me. If you drag your finger across the status bar first, it will receive all touch events for this finger until you lift it. All touch events are delivered to the view in which the touch began.
unfortunately touchesBegan cannot be called from the status bar area.