Test runs fine on iPhone 6s Plus but fails on iPhone 5s - earlgrey

I have a test that selects a particular feed in my app. It works fine on iPhone 6s but fails on iPhone 5s with element not found error. Upon further investigation it seems like the the feed is missing from the view hierarchy. I came up with a workaround which is to something like:
if (running on iPhone 5s) {
// Scroll down by 50 units.
// Then locate the feed and check that it's visible.
[[EarlGrey selectElementWithMatcher:grey_accessibilityID(#"feed10")]
assertWithMatcher:grey_sufficientlyVisible()];
}
Though this seems fine, I'd like to know if there's a better way to conditionally scroll if element isn't found on the screen.

EarlGrey provides the usingSearchAction:onElementWithMatcher: api to find elements that need to be scrolled to in order to find them. Since you're using grey_sufficientlyVisible(), it is required the the element is visible on the screen for the assertWithMatcher check to pass. From their faq, you can change your assertion to be the following:
if (running on iPhone 5s) {
[[EarlGrey selectElementWithMatcher:matcher]
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 50)
onElementWithMatcher:grey_accessibilityID(#"feed10")
assertWithMatcher:grey_sufficientlyVisible()];
}
FYI - you use kGREYDirectionDown since it denotes the direction of the change of the viewport and not the direction of the swipe done for the scroll.

Related

timing of constraints application

I have a UIView in which I display a movie if a particular chapter demands it. This view is resized via constraints in Main.storyboard to adapt to iPhone. All works fine on iPad. It also works fine on iPhone unless the app is asked to reload when a movie containing chapter was last active meaning that a movie will be first-up on loading. In this scenario, the movie is loaded into the iPad dimensions instead of the smaller iPhone specs.
It appears that the constraints on the movie's view are not engaged in a timely manner. The issue centers on a query of the the view's bounds. If I insert a delay before using the bounds the issue goes away. In fact, a delay of 0.0 seconds does the job!
Using a kludge that relies on a delay seems pretty funky to me. I can also move the call that uses the bounds to viewDidLoad to resolve the issue but then I see some underlying “garbage” when reloading the app, the launch image seemingly not in effect. Any suggestions?
It sounds like you're using bounds before your views have been lain out. Without actually seeing your code, I would suggest executing your described code inside of viewDidLayoutSubViews().

Responsive website doesn't scroll smoothly on iPhone

I am having troubles with scrolling on my website on an iPhone.
What I mean by that is that normally, when you start scrolling and then release the display, the site will keep scrolling for a bit on an iPhone. But with this site, it doesn't. As soon as you remove your finger from the display, it will stop scrolling. It is as if the scrolling is sticky.
I really have no idea where I should even begin to look to debug the problem, which is why I am not posting the code (I'd have to post the complete website).
The issue is also not showing up on my Nexus 5. I have had the issue on two different iPhone 5.
I am basically looking for points to start to debug the problem right now.
Apply this script on the master page means if you have a Common layout page :
$(document).ready(function(){
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iPad|iPhone|iPod)/i);
if (agentID) {
$('body').css('-webkit-overflow-scrolling', 'touch');
}
});

Keeping the body background image fixed on the iphone

I have been trying for days to get the background image on my JQM iPhone app to remain fixed and to have the content scroll above it.
Having research many of the answers given I have the following piece of code:
body {
background-image:url(images/background.jpg);
background-attachment:fixed;
}
Using this achieves the desired effect when previewing the app in Safari on my desktop however when I view the app on my iPhone(4s - 6.1.3) the background scrolls with the content.
I have tried many different methods to achieve what I require but so far I have not been successful. As the majority of apps use this method I am sure it is something very simple which I am missing.
Any advice would be gratefully received. Thanks.
Try to use the below one
body {
background-image:url(images/background.jpg);
background-attachment:fixed;
background-size:100%;
}

iOS - How to show hints for gestures for iOS app?

I have seen some apps where when you launch them for the first time after downloading (e.g. Chrome app on iPhone), it shows you a list of animated gestures on the screen, kind of giving you a tour of the app.
How do I build one something like that? And how does the app know to launch only for the first time after download and not since then? For the second question, I am guessing a "shown=TRUE" value can be saved inside a PList file and checking the value each time when the app finished launching. But I am more curious about the mechanism involved in creating a guided app tour.
You can use transparent and semi-transparent images with a UIImageView, so you can make up an image with arrows and notes and put over the whole screen. You could fade it out when the user taps.
To know if it's the first time running the app, you should use NSUserDefaults instead of a plist; it's much easier, and you should be app to find a quick tutorial on that fairly easily.
Also, you could check around on this site for controls like this one. I haven't used any of them myself, so I'm not sure how much they differ from a regular UIImageView. They look nice though.

Intermittent failure of keyboard notofications

I have a view (a couple of them actually) with a standard search bar at the bottom. When the user touches the search bar, I need to move the search bar up so it's not hidden by the keyboard, then down again when the keyboard is dismissed.
I do this the same way as everybody else, by observing UIKeyboardWillShowNotification and UIKeyboardWillHideNotification. From these notifications, I get the height of the keyboard, and that tells me where to put the bottom edge of the search bar. It works perfectly, except for rare cases when the search bar doesn't animate, or doesn't animate far enough, and vanishes behind the keyboard. I have seen this a handful of times out of hundreds of tries with myself and my QA people testing on iPhones and iPods. Just once, I saw the search bar fly off the top of the screen as the keyboard came up. We've never seen any of this on the simulator, and we see it more often on the iPod than the iPhone. We are running iOS 4.x, mostly 4.3.3.
So I can think of two possibilities. One is that very occasionally UIKeyboardWillShowNotification is not sent and the other is that the data in the notification is wrong. The second one would explain the one case where the search bar flew off the top of the screen.
And then of course it is possible that my code is wrong in some very devious way; but the scenario is so simple -- enter the view and tap the search bar -- that I can't see how a bug in my code could cause these rare and intermittent failures.
If anyone can offer insight, I would be very grateful.
I finally discovered the answer to my question, and it's interesting. To cut to the chase, my search bar is animating into the wrong position; in some cases it's still behind the keyboard, and in others it's off the top of the screen. This is not caused by wrong data in the notification, but by a bug in accessing the height member of a CGSize or the y member of a CGPoint.
Specifically: in certain scenarios, when you write mySize.height, the generated code accesses mySize.width. If you are reading, you get the value of mySize.width; if you are writing, you clobber mySize.width. Similarly, myPoint.y actually accesses myPoint.x.
You may never see this problem. I only saw it on older iPod touch devices running iOS 4.2.1, and only in Release builds, and only when compiling with Apple LLVM Compiler 3.0, and then maybe only sometimes. But I reported it to Apple and they say it's a duplicate of a known bug (#10043857) that they are addressing. Connecting a few dots, I am guessing that it's somewhere in the compiler chain in Xcode 4.2.
The workaround is to take the address of the CGSize or CGPoint struct, then use pointer arithmetic to access the desired member. I wrote a set of little helper functions to do this, and I call them all over my app's code.