To set the scene, I'm working on an app that would work similar to guitar hero, but for the piano. Notes come in from the top, and the user has to hit the notes when the notes reach the bottom of the page.
The midi audio of the song is also playing in the background which the user can use as an audio cue and it also plays the left hand for the user.
Okay, so. I have a scrollview which I wish to animate the content offset of so that the notes appear at the top of the screen and come down. I use this:
CGFloat animationTime = [dummySong getDuration] + 2;
[UIView animateWithDuration:animationTime delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
[self.trackScrollView setContentOffset:CGPointMake(self.trackScrollView.contentOffset.x, highestNote.frame.origin.y - (highestNote.frame.size.height - remainderHeightOfLastNote))];
} completion:^(BOOL finished) {
//some code
}];
I use Linear because I don't want it to speed up or slow down weirdly.
The +2 is because I want the notes to start off screen and the height of the scroll view counts for 1 second.
On the simulator (for any simulated device), it behaves perfectly, the audio matches perfectly with the notes coming down from the top of the screen.
On Devices however, the notes arrive too EARLY by differing amounts, based on the device, however it shows no visible signs of overworking the CPU or memory. (this is what confuses me because surely bad / varying performance would relate in UI being delayed?).
Has anyone had the issue of the UIView animateWithDuration behave inconsistently this way?
I'm running out of ideas, as I have tried animating each note UIView down separately but encountered the same problem!
Kind Regards.