我需要一个一个地完成一系列步骤。总之,我有三个步骤要完成,它们都在一个 while 循环中。一旦完成了三个测试,那么只有在那时,用户才应该退出 while 循环。问题是这些步骤需要按顺序完成,并且要求用户按顺序进行每个测试,如果通过,则继续进行下一步。
以下是相关代码:
int passCount = 0;
BOOL flatPass = FALSE;
BOOL landscapePass = FALSE;
BOOL portraitPass = FALSE;
while (passCount < 3) {
if (flatPass == FALSE) {
if (device.orientation == UIDeviceOrientationFaceUp || device.orientation == UIDeviceOrientationFaceDown) {
[self pushSound];
}
}
else if (landscapePass == FALSE) {
if (device.orientation == UIDeviceOrientationLandscapeLeft || device.orientation == UIDeviceOrientationLandscapeRight) {
[self pushSound];
}
}
else if (portraitPass == FALSE) {
if (device.orientation == UIDeviceOrientationPortrait || device.orientation == UIDeviceOrientationPortraitUpsideDown) {
[self pushSound];
}
}
}
我需要用户将 iOS 设备定位在每个位置,并播放哔声表示测试成功。一旦按顺序完成所有三个测试,我希望用户退出循环。我认为每次清除测试时,我都会将 passCount 计数器增加 1,直到达到 3,这将使我退出循环。不过,我的问题是如何按顺序进行每个测试。