同时AVCaptureVideoDataOutput和AVCaptureMovieFileOutput

我需要能够使AVCaptureVideoDataOutput和AVCaptureMovieFileOutput工作。 下面的代码工作,但是,video录制不。 在调用startRecordingToOutputFileURL之后直接调用didFinishRecordingToOutputFileAtURL委托。 现在,如果我通过简单的注释掉AVCaptureVideoDataOutput从AVCaptureSession删除: [captureSession addOutput:captureDataOutput]; video录制的作品,但没有调用SampleBufferDelegate(我需要)。 我怎么能有AVCaptureVideoDataOutput和AVCaptureMovieFileOutput同时工作。 – (void)initCapture { AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo] error:NULL]; captureDataOutput = [[AVCaptureVideoDataOutput alloc] init]; [captureDataOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()]; m_captureFileOutput = [[AVCaptureMovieFileOutput alloc] init]; NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey; NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA]; NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key]; [captureDataOutput setVideoSettings:videoSettings]; captureSession = [[AVCaptureSession alloc] init]; [captureSession addInput:captureInput]; […]

与MapKit ios的渐变折线

我试图使用覆盖(MKOverlay)跟踪MKMapView上的路线。 但是,根据目前的速度,如果颜色正在改变(例如,如果用户从65英里/小时到30英里/小时的速度从绿色变为橙色),则我想在跟踪路线时使用具有渐变的耐克应用程序。 以下是我想要的截图: 所以,每隔20米,我就使用以下方法从旧坐标到新坐标添加覆盖图: // Create ac array of points. MKMapPoint *pointsArray = malloc(sizeof(CLLocationCoordinate2D) * 2); // Create 2 points. MKMapPoint startPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(oldLatitude, oldLongitude)); MKMapPoint endPoint = MKMapPointForCoordinate(CLLocationCoordinate2DMake(newLatitude, newLongitude)); // Fill the array. pointsArray[0] = startPoint; pointsArray[1] = endPoint; // Erase polyline and polyline view if not nil. if (self.routeLine != nil) self.routeLine = […]

iPhone应用程序允许背景音乐继续播放

当声音播放后,立即启动iPhone游戏时,正在播放的背景音乐或播客停止播放。 我注意到其他游戏允许背景audio继续播放。 这怎么可能? 我是否需要重写我的App Delegate中的方法?

如何使用AVCapturePhotoOutput

我一直在使用一个自定义的相机,我最近升级到Xcode 8 beta与斯威夫特3我原本有这样的: var stillImageOutput: AVCaptureStillImageOutput? 但是,我现在得到警告: 在iOS 10.0中不推荐使用“AVCaptureStillImageOutput”:使用AVCapturePhotoOutput 由于这是相当新的,我没有看到这方面的很多信息。 这是我现在的代码: var captureSession: AVCaptureSession? var stillImageOutput: AVCaptureStillImageOutput? var previewLayer: AVCaptureVideoPreviewLayer? func clickPicture() { if let videoConnection = stillImageOutput?.connection(withMediaType: AVMediaTypeVideo) { videoConnection.videoOrientation = .portrait stillImageOutput?.captureStillImageAsynchronously(from: videoConnection, completionHandler: { (sampleBuffer, error) -> Void in if sampleBuffer != nil { let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer) let dataProvider = CGDataProvider(data: […]

自动调整ScrollViewInsets不起作用

我创build了一个非常简单的演示应用程序来testingautomaticallyAdjustsScrollViewInsets的function,但是tableView的最后一个单元格被我的标签栏覆盖。 我的AppDelegate代码: UITabBarController *tabControl = [[UITabBarController alloc] init]; tabControl.tabBar.translucent = YES; testViewController *test = [[testViewController alloc] init]; [tabControl setViewControllers:@[test]]; [self.window setRootViewController:tabControl]; 我的testViewController(UITableViewController的子类)代码: – (void)viewDidLoad { [super viewDidLoad]; self.automaticallyAdjustsScrollViewInsets = YES; self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds]; self.tableView.dataSource = self; self.tableView.scrollIndicatorInsets = self.tableView.contentInset; //[self.view addSubview:self.tableView]; // Do any additional setup after loading the view. } – (NSInteger)tableView:(UITableView […]

在xcode 4.2的scrollview里面devise故事板

我有一个垂直滚动uiscrollview – 想象一个“关于这个应用程序”页面的标签栏应用程序,它有点点,需要一个滚动视图。 它只包含几个图像,一个video和一些文本(只有video已经被编码 – 其余的被放置在GUI中)。 在故事板(界面生成器?)Xcode 4.2中,一切都设置好了,并且工作正常,但是视图只有在屏幕上看到的那么大,是不是可以在故事板上手动排列最初在屏幕外 – 你需要滚动到? 到目前为止,我发现的唯一方法是在可见视图上devise它们,然后使用箭头键导航它们。

支持iPhone 6和iPhone 6以及不同的启动/闪屏图像,适用于iPad纵向和横向方向

我从可用的文档和我的testing中了解到的是 iPhone 6和6 Plus上的所有现有应用程序均以兼容模式运行,这意味着API(如[UIScreen mainScreen] .bounds)将返回320×568(iPhone 5 / 5s),仍在新的iPhone(6/6 Plus)中,所有用户界面通过iOS调整到正确的分辨率。 为了支持iPhone 6 / 6Plus,我们需要为启动屏幕(File-> New-> File-> UserInterace-> Launch Screen)创buildxib,并将nib文件设置为“启动屏幕文件”。 我们可以在启animation面笔尖文件里设置不同的图像,用于启animation面。 [基本上任何组合,常规和紧凑] 无法区分纵向的iPad和横向的iPad(均为普通宽度的普通高度)。 也没有办法区分iPhone 4 / 4s和iPhone 5 / s。 有没有一种方法可以支持iPhone 6/6 Plus模式,还可以在纵向和横向为iPad提供不同的启动图像? 另请参见类似的问题在这里iOS 8的大小类为iPad景观

如何使用CTCallCenter获取呼叫事件:setCallEventHandler:应用程序被挂起时发生的事件?

CTCallCenter的文档:setCallEventHandler:声明: 但是,通话事件也可能在您的应用程序被暂停时发生。 它被暂停时,您的应用程序不会收到通话事件。 当您的应用程序恢复活动状态时,它会为每个改变状态的呼叫接收一个呼叫事件 这个问题的相关部分是 当您的应用程序恢复活动状态时,它会为每个改变状态的呼叫接收一个呼叫事件 暗示该应用程序将收到一个呼叫事件的过去发生的应用程序被暂停时发生。 根据这个问题的答案,这是可能的: Navita TEM应用程序如何获得通话logging信息? 我的问题是:如果我的应用程序被暂停,并且发生了一个调用,那么当我的应用程序恢复活动状态时,如何检索发生的调用事件? 我已经尝试了许多代码实验,但是当我的应用程序恢复到活动状态时,却无法检索到任何呼叫信息。 这是我尝试过的最简单的事情:1)使用Xcode单一视图应用程序模板创build一个新项目。 2)添加如下代码到didFinishLaunchingWithOptions 3)启动应用程序4)任务离开应用程序5)拨打另一个设备的电话,接听电话,挂断来自任一设备的呼叫6)将应用程序带回前台从而恢复活动状态。 注册通话事件的代码是: – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.callCenter = [[CTCallCenter alloc] init]; [self.callCenter setCallEventHandler:^(CTCall *call) { NSLog(@"Event handler called"); if ([call.callState isEqualToString: CTCallStateConnected]) { NSLog(@"Connected"); } else if ([call.callState isEqualToString: CTCallStateDialing]) { NSLog(@"Dialing"); } else if ([call.callState isEqualToString: CTCallStateDisconnected]) { […]

从EventStore EventKit iOS获取所有事件

我想知道如何在iOS中使用EventKit从EventStore获取所有事件。 这样我可以指定今天的所有事件: – (NSArray *)fetchEventsForToday { NSDate *startDate = [NSDate date]; // endDate is 1 day = 60*60*24 seconds = 86400 seconds from startDate NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:86400]; // Create the predicate. Pass it the default calendar. NSArray *calendarArray = [NSArray arrayWithObject:defaultCalendar]; NSPredicate *predicate = [self.eventStore predicateForEventsWithStartDate:startDate endDate:endDate calendars:calendarArray]; // Fetch all events that […]

基于故事板模式的login屏幕示例

我正在学习ios / xcode并在路障中。 我有一个tabbarcontroller +导航的devise。 如果用户没有login,我需要提供一个login屏幕。这里是基本的层次结构。 login页面需要一个导航条(就像我跟着的教程在条上放一个“Go”button。 LoginController: (LTController.h,.m) Main View:TabBarController> NavigationController>View1>View1a NavigationController>View2 我在这里阅读了很多关于模态视图,委托方法等的post。其中大多数是代码片段,不幸的是我的初学者水平有点过头了。 将不胜感激一个简单的解释,如何实现这一点。 特别是文件需要改变的说明会很好。 谢谢