Tag: ios

通过iphone上的HTML5video元素,我如何检测“暂停”和“完成”之间的区别?

这是这个问题的延伸 根据我的研究,对于iPhone / iPad上的video元素,按“完成”和“暂停”触发“暂停”事件。 所以,如果我有一些想要的网页行为,我想按下“完成”button时,我需要听取“暂停”事件。 player = document.getElementById('videoplayer'); player.addEventListener("pause", function() { //desired "done button" behavior defined here }, false); 根据Arv-ToolTwist对原始问题的回答 ,“区分完成”和“暂停”的方式是通过检查webkitDisplayingFullscreen布尔值(因为“完成”button从全屏退出,布尔值将返回false)。 player.addEventListener("pause", function() { if(!player.webkitDisplayingFullscreen) { //desired "done button" behavior defined here } }, false); 然而,在用户在全屏模式下暂停video,然后在暂停video时按下“完成”的情况下,不会启动“期望的完成button行为”。 我的研究是关于这个问题的小信息,但是我的假设是,“暂停”事件不会被第二次触发,或者在webkitDisplayingFullscreen布尔值更改为“false”之前被第二次触发。 。 无论哪种方式,该设备可以告诉“完成”和“暂停”之间的差异(即使玩家已经暂停),所以我想知道 如何设备告诉差异,和 是否有办法检测播放器何时退出全屏模式,以便即使当播放器已经暂停时,仍然检测到按下“完成”button并且仍然开始期望的行为。

MPMoviePlayerController全屏旋转,而父视图控制器仅支持纵向

这个问题只是我的问题的一部分。 我正在为我现有的应用程序实现iOS6旋转和定向支持。 所以我有一个ViewController,它包含一个embedded在ViewController视图中的MPMoviePlayerController(我的应用程序需要它)。 用户可以播放video并在embedded式视图中查看,或使用默认播放器控件点击全屏button,播放器进入全屏模式。 现在我已经限制视图控制器只支持使用iOS6提供的新的旋转API的纵向方向。 // New Autorotation support. – (BOOL)shouldAutorotate; { return NO; } – (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 这工作得很好。 ViewController只支持肖像和用户在embedded式视图中播放电影。 现在问题来了,当用户进入全屏模式。 在全屏模式下,当我旋转模拟器/设备时,电影保持旋转。 当我旋转设备而在全屏幕模式下使用shouldAutorotate和supportedInterfaceOrientations断点播放电影时,它仍然在这两个方法分别返回NO和UIInterfaceOrientationMaskPortrait ,但仍然电影正在旋转… 为什么发生这种情况? ….这是我的问题的一部分…第二部分是我想要电影进入横向模式,当用户转到全屏模式。 我希望电影播放器​​locking在横向模式,直到用户按下“完成”button。 请帮忙 ….

有没有一种实用的方法来压缩NSData?

我还没有看到关于这个主题的任何文档,但是这并不意味着它不存在。

如何序列化包含NSNull的NSDictionary / NSArray / Property List(plist)

我想存储在NSMutableDictionary使用NSNull一些空值,然后使用属性列表序列化这些数据。 问题是NSNull是不允许的,我得到“属性列表格式无效”的错误。 有没有解决方法? 似乎很奇怪,他们没有把NSNull放在有效的plist对象列表中。

点击或滚动后,asynchronous下载的图像只出现在UITableView中

我成功地从博客文章加载我的UITableViewasynchronous缩略图。 我遇到的问题是,只有当我点击单元格或向下滚动时才会显示图像。 当我点击单元格时,图像出现在左侧,将标题和字幕推向右侧。 当我向下滚动时,图像出现在细胞应该显示的位置。 这是我的代码(我正在使用AFNetworking): #import "UIImageView+AFNetworking.h" – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return posts.count; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } NSDictionary *post = [posts objectAtIndex:indexPath.row]; NSString *postpictureUrl = [post objectForKey:@"picture"]; [cell.imageView […]

如何解决iOS中的video定位问题

我正在使用一个应用程序,用户从照片中挑选video并将其上传到服务器。 由于我的服务器是.Net服务器,video被旋转。 我知道问题的原因可能是相同的情况下的形象(你可以参考我以前的回答https://stackoverflow.com/a/10601175/1030951 ),所以我GOOGLE了,并得到了一个代码来解决video方向 ,我从RayWenderlich.com获得了一个代码,并按照以下方式修改。 现在我的输出video工作正常,但video静音。 它播放,但不播放audio。 请帮助我,如果我失去了一些东西。 我传递信息字典-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info方法 – (void)fix:(NSDictionary*)pobjInfoDirectory withFileName:(NSString*)pstrOutputFileName { firstAsset = [AVAsset assetWithURL:[pobjInfoDirectory objectForKey:UIImagePickerControllerMediaURL]]; if(firstAsset !=nil) { //Create AVMutableComposition Object.This object will hold our multiple AVMutableCompositionTrack. AVMutableComposition* mixComposition = [[AVMutableComposition alloc] init]; //VIDEO TRACK AVMutableCompositionTrack *firstTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; [firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, firstAsset.duration) ofTrack:[[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil]; […]

iOS:audio录制文件格式

我正在实施audio录制。 它适用于caf & wave格式。 但问题是文件大小太大。 所以,任何人都可以帮助我loggingaudio格式,也发挥在窗口和文件大小是低的。 我试过的代码如下: dirPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; NSString *soundFilePath = [docsDir stringByAppendingPathComponent:@"sound.wave"]; NSLog(@"%@",soundFilePath); NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath]; NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey, [NSNumber numberWithInt:16], AVEncoderBitRateKey, [NSNumber numberWithInt: 2], AVNumberOfChannelsKey, [NSNumber numberWithFloat:8000.0], AVSampleRateKey, [NSNumber numberWithInt:8], AVLinearPCMBitDepthKey, nil]; NSError *error = nil; audioRecorder […]

Xcode 4.3.2绕过代码签名

我使用Xcode 4.3.2来编译Cydia应用程序。 4.1有一个简单的方法来允许未签名的应用程序构build(plist编辑),但是,在4.3.2中,它不具有编辑plist文件的简单性。 现在,在4.3.2中,我收到这个错误: CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 5.1' 所以我的问题是,如何绕过Xcode 4.3.2中的代码签名? 谢谢!

对许多包含数字的NSArray进行sorting

我有一个NSArray的填充NSMuttableArray对象。 这些对象中的大多数具有“1”,“2”,“3”,“4”,“5”等整数值,有时会有“家”,“最左”或“最右”的名称。 我正在尝试使用sortedArrayUsingSelector对Objective C中的数组进行sorting:@selector(compare :)在数组less于10的情况下工作正常。 但是当它有更多我开始得到“1”,“10”,“11”,“12”,“2”,“3”types的东西。 非常感激任何的帮助。 该代码不应该返回任何东西。 只需要分类并继续前进。 原始代码: presetNamesSort = [[[NSMutableArray alloc]init]retain]; presetNamesSort = [presetNames sortedArrayUsingSelector:@selector(compare:)];

将字块中的块保留

我有我自己的方法,把块作为一个参数。 我想跟踪在NSDictionary内的块。 将字块添加到字典的最佳方法是什么? 我试过这个代码,但执行下面的行(setObject …)后,字典仍然是空的。 我认为这是因为该块不是NSObjecttypes。 但是,这样做的正确方法是什么? – (void)startSomething:(NSURLRequest*)request block:(void (^)(NSURLResponse*, NSData*, NSError*))handler { NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self]; [pendingRequests setObject:handler forKey:connection]; } 编辑: 没关系。 我不知道我在想什么。 3分: 块是objc对象 Typo:setObject应该是setValue forKey是一个string,所以它应该是[连接描述]或类似的东西 无论如何,我现在解决我的问题是这样的: – (void)startSomething:(NSURLRequest*)request block:(void (^)(NSURLResponse*, NSData*, NSError*))handler { NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self]; [pendingRequests setValue:handler forKey:[connection description]]; } – (void)connectionDidFinishLoading:(NSURLConnection *)connection { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, […]