Tag: Objective C

iOS – 缩放和裁剪CMSampleBufferRef / CVImageBufferRef

我正在使用AVFoundation并从AVCaptureVideoDataOutput获取示例缓冲区,我可以直接写入到videoWriter使用: – (void)writeBufferFrame:(CMSampleBufferRef)sampleBuffer { CMTime lastSampleTime = CMSampleBufferGetPresentationTimeStamp(sampleBuffer); if(self.videoWriter.status != AVAssetWriterStatusWriting) { [self.videoWriter startWriting]; [self.videoWriter startSessionAtSourceTime:lastSampleTime]; } [self.videoWriterInput appendSampleBuffer:sampleBuffer]; } 我现在要做的是在CMSampleBufferRef中裁剪和缩放图像,而不将其转换为UIImage或CGImageRef,因为这会降低性能。

支持不同的方向只有一个视图的iOS 6

我只想旋转我的应用程序中的一个我的意见,左或右风景。 我所有的其他意见是在肖像模式,我已经设置我的应用程序只支持肖像模式。 在iOS 6中改变方向,我不知道如何做到这一点。 我已经尝试下面张贴如下。 谁能告诉我我做错了什么? 谢谢! -(BOOL)shouldAutorotate { return YES; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; } -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft; } 我也试过了: -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; return YES;//UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft; } -(void)didRotate:(NSNotification *)notification { UIDeviceOrientation orientation = [[notification object] orientation]; if (orientation == […]

iOS9 – 这个应用程序正在从后台线程修改自动布局引擎 – 在哪里?

对于search,错误消息是: 此应用程序正在从后台线程修改自动布局引擎,这可能会导致引擎损坏和怪异的崩溃。 这将在未来的版本中引起exception。 我知道这意味着一些UIKit代码是从后台线程调用的,我知道解决scheme是包装代码 dispatch_async(dispatch_get_main_queue(), ^(void){ <code> }); 我的问题是定位在哪里做,因为没有任何印刷的堆栈跟踪引用我的应用程序代码。 我的证据certificate这个消极的是在debugging输出窗口中search(命令-f)我的应用程序的名称; 我有24堆栈跟踪倾倒出来,我的应用程序名称是不是在其中任何一个,除了在错误信息的顶部。 我可以发布其中之一,但这似乎不是很有用。 在我今天正在处理的情况下,在viewWillDisappear()和viewWillAppear()之前转换视图控制器时发生这种情况。 我已经find了我的代码的一部分来包装dispatch_async() ,但是这些都是现在处理的。 我有与视图控制器相关的对象被分配和释放的断点和debugging消息,并且它们都在exception消息出现之后触发。 在模拟器和我的iOS9 iPhone上都发生这种情况,无论是在debugging模式还是释放模式。 我如何识别显然修改UI的后台代码?

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

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

自动调整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 […]

XMPPFramework – 如何创buildMUC房间并邀请用户?

我正在使用Robbiehanson的iOS XMPPFramework。 我正在尝试创build一个MUC房间,并邀请用户join群组聊天室,但这不起作用。 我正在使用下面的代码: XMPPRoom *room = [[XMPPRoom alloc] initWithRoomName:@"user101@conference.jabber.org/room" nickName:@"room"]; [room createOrJoinRoom]; [room sendInstantRoomConfig]; [room setInvitedUser:@"ABC@jabber.org"]; [room activate:[self xmppStream]]; [room inviteUser:jid1 withMessage:@"hello please join."]; [room sendMessage:@"HELLO"]; 用户ABC@jabber.org应该收到邀请信息,但没有任何事情发生。 任何帮助将不胜感激。 🙂

如何获得AFNetworking 2.0的下载进度?

我正在使用AFURLSessionManager来创build一个新的下载任务: AFURLSessionManager* manager = … NSProgress* p = nil; NSURLSessionDownloadTask* downloadTask = [manager downloadTaskWithRequest:request progress:&p destination:^NSURL*(NSURL* targetPath, NSURLResponse* response) {…} completionHandler:^(NSURLResponse* response, NSURL* filePath, NSError* error) {…} ]; [downloadTask resume]; 该文件得到下载罚款,但是,我怎么得到进展通知? p总是设为零。 我为此提出了一个问题 。 我也尝试在pipe理器上调用setDownloadTaskDidWriteDataBlock ,并在那里获取进度通知,但是在文件下载完成后 ,我将它们全部分组。 看起来这个区域在AFNetworking 2.0中还是有点bug的 有任何想法吗?

检测iOS应用程序是否在debugging器中运行

我将我的应用程序设置为将debugging输出发送到控制台或日志文件。 现在,我想在代码中决定是否 它在debugging器(或模拟器)中运行,因此有一个控制台窗口,我想直接读取输出或如果 没有控制台窗口,因此,输出应该被redirect到一个文件。 有没有一种方法来确定应用程序是否在debugging器中运行?

查看viewWillAppear:和viewDidAppear之间的框架变化:

我在我的应用程序中发现了一个奇怪的行为,其中一个连接的IBOutlet在我的视图控制器中对viewWillAppear:和viewDidAppear:之间的连接视图的框架。 这里是我的UIViewController子类中的相关代码: -(void)viewWillAppear:(BOOL)animated { NSLog(@"%@", self.scrollView); } -(void)viewDidAppear:(BOOL)animated { NSLog(@"%@", self.scrollView); } 并生成日志输出: MyApp[61880:c07] <UIScrollView: 0x1057eff0; frame = (0 0; 0 0); clipsToBounds = YES; autoresize = TM+BM; gestureRecognizers = <NSArray: 0x10580100>; layer = <CALayer: 0x1057f210>; contentOffset: {0, 0}> MyApp[61880:c07] <UIScrollView: 0x1057eff0; frame = (0 44; 320 416); clipsToBounds = YES; autoresize = TM+BM; gestureRecognizers […]

如何将NSDate转换为“今天”,“昨天”,“一周前”,“一个月前”,“一年前”的相对格式?

我想将nsdate转换为"Today","Yesterday","a week ago","a month ago","a year ago","date as it is"等相对格式。 我已经为它写了下面的方法..但一些如何它只是打印,因为它是date..你能告诉我应该是什么问题? //以下是将date转换为相对string的函数 +(NSString *)getDateDiffrence:(NSDate *)strDate{ NSDateFormatter *df = [[NSDateFormatter alloc] init]; df.timeStyle = NSDateFormatterMediumStyle; df.dateStyle = NSDateFormatterShortStyle; df.doesRelativeDateFormatting = YES; NSLog(@"STRING DATEEE : %@ REAL DATE TODAY %@",[df stringFromDate:strDate],[NSDate date]); return [df stringFromDate:strDate]; } 我有以下格式的datestring"2013-10-29T09:38:00" 当我试图给NSDate对象时,它总是返回我空date。 所以我试图将该date转换为yyyy-MM-dd HH:mm:ssZZZZ然后我将这个date传递给函数,然后它只是打印整个date.. 如何解决这个问题呢? //以下是我称之为上述function的代码 NSDateFormatter *formatter = [[NSDateFormatter alloc] […]