我制作了一个成功的视频录制节目,但它没有音频?我该怎么做才能解决这个问题?我已经在我的设置中正确设置了音频权限info.plist.我正在使用AVCaptureFileOutputRecordingDelegate.
override func viewWillAppear(_ animated: Bool) {
let deviceDiscoverySession = AVCaptureDeviceDiscoverySession(deviceTypes: [AVCaptureDeviceType.builtInDuoCamera, AVCaptureDeviceType.builtInTelephotoCamera,AVCaptureDeviceType.builtInWideAngleCamera], mediaType: AVMediaTypeVideo, position: AVCaptureDevicePosition.back)
for device in (deviceDiscoverySession?.devices)!{
if(device.position == AVCaptureDevicePosition.back){
do{
let input = try AVCaptureDeviceInput(device: device )
if captureSession.canAddInput(input){
captureSession.addInput(input)
}
// sessionOutput.videoSettings = [(kCVPixelBufferPixelFormatTypeKey as NSString) : NSNumber(value: kCVPixelFormatType_420YpCbCr8BiPlanarFullRange as UInt32)]
sessionOutput.alwaysDiscardsLateVideoFrames = true
if(captureSession.canAddOutput(sessionOutput) == true){
captureSession.addOutput(sessionOutput)
let previewLayer: AVCaptureVideoPreviewLayer = {
let preview = AVCaptureVideoPreviewLayer(session: self.captureSession)
preview?.bounds = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height)
preview?.position = …Run Code Online (Sandbox Code Playgroud) 我使用下面的类制作了子弹列表和精灵列表.如何检测子弹是否与精灵碰撞,然后删除该精灵和子弹?
#Define the sprite class
class Sprite:
def __init__(self,x,y, name):
self.x=x
self.y=y
self.image = pygame.image.load(name)
self.rect = self.image.get_rect()
def render(self):
window.blit(self.image, (self.x,self.y))
# Define the bullet class to create bullets
class Bullet:
def __init__(self,x,y):
self.x = x + 23
self.y = y
self.bullet = pygame.image.load("user_bullet.BMP")
self.rect = self.bullet.get_rect()
def render(self):
window.blit(self.bullet, (self.x, self.y))
Run Code Online (Sandbox Code Playgroud) 我正在为我正在研究的Swift iPad应用程序寻找一个IOS PDF查看器.使用UI Web View实际上没有足够的功能来使应用程序顺利运行.这就是我需要的:
我知道并非所有这些都与实际的PDF查看器有关,但我列出了它们,因为它们最终需要使用PDF查看器.我非常不愿意尝试使用其中的众多PDF查看器中的一个,因为我正在寻找看起来很专业且非常简单的东西.
我应该使用PDF查看器工具包还是尝试自定义UI Web View?我不知道在这种情况下该怎么做.感谢帮助!
如果我在故事板中有一个视图设置,是否有一种方法可以让我的视图(自定义宽度和高度)在按下按钮时从屏幕底部向上滑动?我希望屏幕只是叠加(这样你仍然可以按下屏幕下面的东西).
我该如何设置?
func isChecked(){
let window = UIApplication.sharedApplication().keyWindow
window!.addSubview(collectionView)
let height: CGFloat = 250
let y = window!.frame.height - 250
collectionView.frame = CGRect(x: 0, y: window!.frame.height, width: window!.frame.width, height: height)
UIView.animateWithDuration(0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .CurveEaseOut, animations: {
self.collectionView.frame = CGRectMake(0, y, self.collectionView.frame.width, self.collectionView.frame.height)
}, completion: nil)
}
func isUnchecked(){
let window = UIApplication.sharedApplication().keyWindow
UIView.animateWithDuration(0.3, animations: {
self.collectionView.frame = CGRectMake(0, window!.frame.height, self.collectionView.frame.width, self.collectionView.frame.height)
})
}
Run Code Online (Sandbox Code Playgroud)
有没有办法可以完成我上面的工作,除了我在故事板中创建的视图?
我有一个视频录制应用程序,我想知道是否可以创建一个button显示“查看相机胶卷”的应用程序,当您单击该按钮时,它会启动手机上的照片应用程序。
我看到类似这样的东西的常见用途是UIImagePickerController在我的实际应用程序中,它接近我想要的,但我不希望用户选择一个除了查看它和浏览他们的照片之外的其他东西。如果有一个指向实际照片应用程序的链接会更容易。
对于我的编程任务,我被要求编写一个通用的复制方法,从一个数组复制到相同大小和类型的数组.这在Java中甚至可能吗?我尝试的一切都以一些"通用数组创建"错误结束.我迷路了,不知道怎么解决这个问题!
public class copyArray<AnyType>{
public copyArray(AnyType[] original){
AnyType[] newarray = new AnyType[original.length];
for(int i =0; i<original.length; i++){
newarray[i] = original[i]; }
}
Run Code Online (Sandbox Code Playgroud) 我有一个详细视图控制器,我想使用indexPath行将标签文本设置为从数组中获取的值.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if(segue.identifier == "showView"){
let detailVC: DetailViewController = segue.destinationViewController as! DetailViewController
let indexPath = self.MainTableView.indexPathForSelectedRow!
detailVC.label.text = "Test"
self.MainTableView.deselectRowAtIndexPath(indexPath, animated: true)
}
}
Run Code Online (Sandbox Code Playgroud)
我一直遇到一个致命的错误:在解开一个可选值时意外地发现了nil.我尝试过切换detailVC.label.text = "Test",detailVC.label.text = names[indexPath.row]但每次都会遇到同样的错误.
我使用相同的代码行来更改单元格的标签文本,没有错误,但对于这个标签在空白视图的中心我似乎无法正确使用它?有什么需要改变的想法?
顺便说一下,详细视图控制器中的标签是 @IBOutlet weak var label: UILabel!