Tag: cocoa touch

获取iOSvideo的时间戳/位置

我可以使用Image Picker获取.MOV文件,但是如何才能find拍摄地点和拍摄时间? 我的图像select器: – (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType]; [self dismissViewControllerAnimated:NO completion:nil]; // Handle a movie capture if (CFStringCompare ((__bridge_retained CFStringRef)mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo) { NSString *movieFile = [[info objectForKey: UIImagePickerControllerMediaURL] path]; NSURL *movieURL = [NSURL fileURLWithPath:movieFile]; NSLog(@"Movie File %@",movieURL); [self dismissViewControllerAnimated:YES completion:nil]; } }

奇怪的崩溃,如果我试图释放CXMLDocument

我正在使用TouchXMLparsing一些XML,我正在碰到-EXC_BAD_ACCESS。 我通过反复试验发现,如果我不释放我的CXMLDocument(我分配),那么一切都很好。 这是我的代码: – (NSArray *)getLookUps { //Do some stuff and then… NSData *tempData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; CXMLDocument *xmlDoc = [[CXMLDocument alloc] initWithData:tempData options:0 error:nil]; NSDictionary *mappings = [NSDictionary dictionaryWithObject:@"http://****/****" forKey:@"****"]; NSLog(@"%@", [[NSString alloc] initWithData:tempData encoding:NSUTF8StringEncoding]); NSArray *orders = [[xmlDoc rootElement] nodesForXPath:@"//****:Unit" namespaceMappings:mappings error:nil]; NSMutableArray *units = [NSMutableArray arrayWithCapacity:200]; for (CXMLElement *order in […]

我试图使用NSHost和XCode没有认出它

我试图添加一个NSHost方法,XCode不能识别它。 你知道这是为什么吗?

UINavigationController过渡animation触发得太快

我在我的字典应用程序中使用定制的容器视图控制器。 基本上,容器视图控制器包含顶部的自定义导航栏( 不是一个UINavigationBar只是一个带有后退和前进UIButtons的UIView ,一个UISearchBar和一个书签UIButton )和底部的标签栏控制器。 我的问题是这样的:我使用后退和前进button来推送和popup视图控制器在其中一个选项卡( UINavigationController ),以便用户可以浏览字典浏览历史logging。 但是,如果我太快按下后退或前进button,我会在日志窗格中看到此消息,并且一些屏幕完全不显示: 对<DefinitionViewController:0x8e5d230>开始/结束外观转换的不平衡调用。 回顾一下StackOverflow,我明白这是因为点击后退或前进button太快会调用活动选项卡中的UINavigatonController的push / pop方法,但它不会让animation完成。 https://stackoverflow.com/a/17440074/855680 推动或popup视图控制器没有animation解决了这个问题,但我确实想保持animation。 我怎样才能解决这个问题? 我查看了UINavigationController类的引用,看是否有任何委托方法或属性指示它在animation的中间,但似乎没有。

如何使用代码显示SomeViewControler?

我在Xcode和iOS开发中是全新的。 我想弄清楚如何打开/显示基于button点击一些视图。 我知道我可以做到这一点使用Ctrl +鼠标点击一些ViewController使用segue,但我需要添加一些逻辑之前。 我怎样才能做到这一点?

为什么一个子视图不会留在父框架?

我有一个看法,里面有一个UIImage 。 图像不是静态的,我可以移动它,如果我拖动我的手指(使用拖动事件)问题是,有时图片移动到UIView框架之外。 什么是适当的方法来保持它在父框架边界? –UIViewA ——– UIViewB ————–的UIImage ————–的UIButton 我想保持UIViewB里面的UIImage – (IBAction)myButtonSingleTap:(UIButton *)sender { imDragging = YES; [_myButton addTarget:self action:@selector(dragBegan:withEvent:) forControlEvents: UIControlEventTouchDown]; } – (IBAction)myButtonDragInside:(UIButton *)sender { [_myButton addTarget:self action:@selector(draging:withEvent:) forControlEvents: UIControlEventTouchDragInside]; } – (void)dragBegan:(UIControl *)c withEvent:ev { UITouch *touch = [[ev allTouches] anyObject]; startingTouchPoint = [touch locationInView:self.view]; } – (void)draging:(UIControl *)c withEvent:ev { UITouch […]

在iOS中,可以通过alloc和initWithFrame添加一个UIButton?

button可以通过以下方式添加: UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; myButton.frame = CGRectMake(100, 100, 160, 50); [myButton setTitle:@"click me" forState:UIControlStateNormal]; [self.view addSubview:myButton]; 但是我们可以使用initWithFrame方法: UIButton *myButton2 = [[UIButton alloc] initWithFrame:CGRectMake(100, 300, 160, 50)]; //myButton2.buttonType = UIButtonTypeRoundedRect; myButton2.titleLabel.text = @"click me"; [self.view addSubview:myButton2]; 但上面的第2行被注释掉,因为它导致了一个“只读”属性的错误,并与该行注释,仍然没有任何button显示…可以添加一个UIButton,如果使用initWithFrame开始? ( 更新:我设置了一个黄色背景来查看视图的区域,并发现button2的标签文本实际上显示为“点击我”白色但触摸它没有视觉效果…所以我想知道更改代码示例2使其工作…)

如何将CGContextRef保存为.PNG文件?

我创build一个绘图iOS应用程序,我想创build一个“保存图像”方法。 绘图发生在touchesMoved:方法内。 – (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; [self drawToCache:touch]; [self setNeedsDisplay]; } – (void) drawToCache:(UITouch*)touch { hue += 0.005; if(hue > 1.0) hue = 0.0; UIColor *color = [UIColor colorWithHue:hue saturation:0.7 brightness:1.0 alpha:1.0]; CGContextSetStrokeColorWithColor(cacheContext, [color CGColor]); CGContextSetLineCap(cacheContext, kCGLineCapRound); CGContextSetLineWidth(cacheContext, 15); CGPoint lastPoint = [touch previousLocationInView:self]; CGPoint newPoint = […]

UIAlertViewStyleLoginAndPasswordInput与更多的TextFields?

它可能添加更多的TextFields到UIAlertViewStyleLoginAndPasswordInput? 我怎么办? 或者还有其他的可能性?

请求NSPhotoLibraryAddUsageDescription权限

我试图将图像保存到iOS 10和11版本的照片应用程序。 因此,在iOS 11上,我需要请求NSPhotoLibraryAddUsageDescription权限,在iOS 10 NSPhotoLibraryUsageDescription 。 正如苹果文档所声称的那样 , [PHPhotoLibrary requestAuthorization:] 仅为 NSPhotoLibraryUsageDescription项获取权限。 如果您在Info.plist文件中同时拥有两个按键,并且在应用Info.plistselect了“仅将照片添加到照片”权限,则[PHPhotoLibrary authorizationStatus]将返回PHAuthorizationStatusDenied 。 有人知道如何处理这些权限?