iPhone 可以站在地上,当它振动时,它会在地上旋转 所以我们可以利用这个功能拍一张全景照片。 实际上有一个应用程序的功能与我上面写的相同。该应用程序称为“Cycloramic” 它可能毫无意义,但我想构建这个应用程序来学习 iOS 编程。
现在我遇到了一个问题,它只是振动,忽略了拍照的一部分。
这是代码。
当我按下按钮时,它开始了。
首先,它会拍照,然后振动,直到旋转 29 度。然后再拍一张照片。 这就是它的功能。
但是,当我启动应用程序时,它只会振动,根本不会拍照。
有什么问题吗?
if([self.rangeSelectionButton.title isEqualToString:@"90"])
{
range = 90;
}
else if ([self.rangeSelectionButton.title isEqualToString:@"180"])
{
range = 180;
}
else if ([self.rangeSelectionButton.title isEqualToString:@"270"])
{
range = 270;
}
else if ([self.rangeSelectionButton.title isEqualToString:@"360"])
{
range = 360;
}
else
{
return;
}
switch (range)
{
case 90:
[self.imagePickerController takePicture];
[self.motionSensor updateGyro];
self.beforeRoll = self.motionSensor.roll;
for(;(self.motionSensor.roll - self.beforeRoll) <= 29;){
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
[self.motionSensor updateGyro];
}
[self.imagePickerController takePicture];
[self.cameraTimer fire];
break;
case 180:
break;
case 270:
break;
case 360:
break;
default:
break;
}
我在上面发布了完整的代码。 if 语句检查我想要拍照的角度。
根据角度,switch 语句起作用。我只写了 90 度角的部分。 谢谢。
最佳答案
来自docs对于 takePicture
:
Calling this method while an image is being captured has no effect. You must wait until the associated delegate object receives an
imagePickerController:didFinishPickingMediaWithInfo:
message before you can capture another picture.
您确定已捕获原始图像吗?
我认为 UIImagePickerController
不是适合您尝试执行的操作的正确库。使用 AVFoundation 可能是一个更好的主意。得到你想要的照片。
Apple还提供了示例项目AVCam展示如何实现这一目标。
关于ios - 我正在制作一个可以自行拍摄全景照片的 iOS 应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24403699/