Tag: cocoa触摸

UILabel导致应用程序在添加到视图时崩溃(仅限Xcode 6和iOS 8)

我已经将我的项目转换为Xcode 6,以便为iOS 8构build。但是,特定的UILabel会导致应用程序在添加到视图层次结构时崩溃。 这是我收到的唯一错误日志: -[MyViewController _contentInsetsFromFonts]: unrecognized selector sent to instance 0x16d90da0 我一直无法find我的项目中的任何地方contentInsetsFromFonts方法。 另外,我还没有能够在网上find任何地方的参考,包括苹果的文档。 我没有使用这个UIViewController的NIB,所以UI是在loadView方法中构build的: – (void)loadView { UIImage *trackImage = [UIImage imageNamed:@"sliderTrack.png"]; sliderBackground = [[UIImageView alloc] initWithImage:trackImage]; UIView *view = [[UIView alloc] initWithFrame:sliderBackground.frame]; [view addSubview:sliderBackground]; slider = [[UISlider alloc] initWithFrame:sliderBackground.frame]; CGRect sliderFrame = slider.frame; sliderFrame.size.width -= 46; slider.frame = sliderFrame; slider.center = sliderBackground.center; slider.backgroundColor […]

使用 – observeValueForKeyPath:ofObject:change:context:在Swift 3中

我试图将Swift 2.2项目转换为Swift 3,我得到以下错误: Method 'observeValue(forKeyPath:ofObject:change:context:)' with Objective-C selector 'observeValueForKeyPath:ofObject:change:context:' conflicts with method 'observeValue(forKeyPath:of:change:context:)' from superclass 'NSObject' with the same Objective-C selector" for the function call 在我的function上签名是: func observeValue(forKeyPath keyPath: String?, ofObject: Any?, change: [String : Any]?, context: UnsafeMutableRawPointer?)." 我已阅读Swift 3 Migration Guide网站上的build议: “解决方法:在使用最初的Objective-Cselect器实现可选需求之前添加@objc(objectiveC:name :)属性。 但是我不清楚这实际上是应该在源文件中应用的,到目前为止我没有尝试过。 任何人都可以解释如何正确设置?

尝试呈现其视图不在窗口层次结构中的UIViewController

我有一个多视图应用程序与以下层次结构: 启动 – >导航控制器 – >表格视图控制器 – >设置视图控制器 Splash是应用程序入口点,因此成为根视图控制器。 当我尝试通过设置视图控制器上的操作向乐队添加拼贴时,出现debugging器警告: 应用程序[1929:1000746]警告:尝试在<SplashViewController:0x15dd597b0>上呈现其视图不在窗口层次结构中的<MSBAddTileDialogViewController_iOS:0x15f0575b0>! 这发生在MSBClient.tileManager addTile:completionHandler:调用之后MSBClient.tileManager addTile:completionHandler: 调用永不返回,不会产生错误。 有关如何解决这个问题的任何build议?

与Cocoapod的Xcode错误:“该文件无法保存。 该文件不存在“

我已经将SPGooglePlacesAutocomplete cocoapod添加到了我的项目中 – 而且我遇到了一个非常奇怪的问题。 当我尝试运行我的项目时,Xcode说在Pod的头文件中有一个错误: SPGooglePlacesAutocompleteQuery.h:65:23: Unknown type name 'CGFloat' 尝试调整该文件中的任何内容(如导入UIKit)会导致错误:“文档SPGooglePlacesAutocompleteQuery.h无法保存,该文件不存在” 什么可以使Xcode这个文件是不存在的?

如何使NSAssert在Xcode4中logging说明?

Xcode 4告诉我什么时候NSAssert失败了,但是断言描述和回溯不再被logging。 我看到了这个问题: 如何使Xcode4停止在NSAssert失败? 这是有帮助的,但我宁愿logging断言,继续。 我怎样才能使NSAssert这样的行为? 谢谢!

MKMapView – 删除注释导致应用程序崩溃

从我的地图视图中删除注释以下列方式: if ([[self.mapView annotations] count] > 0) { [self.mapView removeAnnotations:[self.mapView annotations]]; } 导致我的应用程序崩溃,出现以下exception: *** Terminating app due to uncaught exception 'NSRangeException', reason: 'Cannot remove an observer <MKAnnotationContainerView 0xe87b420> for the key path "title" from <PFAnnotation 0x10851230> because it is not registered as an observer.' 注释按以下方式添加: CLLocationCoordinate2D pinPosition; for (int index = 0; index < [array […]

自定义字体不在设备上显示,但在模拟器上

我一直在使用iOS中的自定义字体,并且除了自定义字体不会显示在我的任何设备上外,大部分情况已经解决了。 我已经添加了字体到项目文件的根目录。 将其添加到数组下的info.plist文件或“应用程序提供的字体” 检查了原始文件和我添加到info.plist文件的大小写是否相同。 使用[playMenuBtn.titleLabel setFont:[UIFont fontWithName:@"fontname" size:40]]; 使字体工作。 当我在模拟器中运行我的应用程序时,它都显示正常,并工作。 但是,只要我在物理设备上运行它,它会显示默认大小的默认字体。 如果我使用: UIFont *font = [UIFont fontWithName:@"VINCASTENCIL" size:20]; NSLog(@"Font:%@", font); 然后模拟器返回: 2012-04-07 01:10:41.544 AppName[47412:f803] Font:<UICFFont: 0x683e040> font-family: "VINCA STENCIL"; font-weight: normal; font-style: normal; font-size: 20px 2012-04-07 01:10:41.544 AppName[47412:f803] Font:<UICFFont: 0x683e040> font-family: "VINCA STENCIL"; font-weight: normal; font-style: normal; font-size: 20px 当设备返回时: 2012-04-07 00:42:56.358 AppName[5079:707] Font:(null) 我已经尝试了所有的东西,包括尝试FontBook告诉我字体可以被命名的所有名称。 […]

和之间的区别

调用以下types的方法有什么区别? 1。 [self methodName]; 和 2。 [self performSelector:@selector(methodName)]; // no afterDelay is used 是不是像performSelector将使用不同的线程工作?

如何重试基于块的URL请求

我使用iOS7的新的URL请求方法来获取数据,如下所示: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[self.baseUrl stringByAppendingString:path]]]; NSURLSessionDataTask *dataTask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response; NSUInteger responseStatusCode = [httpResponse statusCode]; if (responseStatusCode != 200) { // RETRY (??????) } else completionBlock(results[@"result"][symbol]); }]; [dataTask resume]; 不幸的是,我不时得到HTTP响应,指出服务器不可达( response code != 200 ),需要重新发送相同的请求到服务器。 如何才能做到这一点? 我如何才能完成我的代码片段上面我的评论// RETRY ? 在我的例子中,成功获取后调用完成块。 […]

AppDelegate文件在哪里适合MVC?

我正在学习iPhone / iPad编程。 我相信我理解MVC的概念; 我很难理解如何在正常的iPhone / iPad应用程序中的一些文件适合MVC。 当您使用“基于视图的应用程序”模板创build新的应用程序时,会创build一个AppDelegate.m和AppDelegate.h文件。 这是一个模型,视图或控制器文件? 我猜这实际上没有那些。 我希望我能看到一个图表或stream程图,显示应用程序中每个文件所属的类别。