Tag: cocoa touch

iOS – NSOperation内的asynchronousNSURLConnection

我知道这个问题在这个问题上被问了很多次,但是我没有设法使它在我的项目中工作。 所以,我想要NSOperation子类,并使用NSURLConnection下载文件。 什么是正确的方法来做到这一点? 这是我的代码不起作用:首先,我将所有的操作添加到循环中: DownloadFileOperation *operation; NSOperationQueue *queue = [[NSOperationQueue alloc] init]; for (int i=0; i<10; i++) { operation = [[DownloadFileOperation alloc] init]; operation.urlString = pdfUrlString; [queue addOperation:operation]; operation = nil; } 这是我的子类: @interface DownloadHandbookOperation : NSOperation <NSURLConnectionDelegate> { } @property (strong, nonatomic) NSString *urlString; @end @implementation DownloadHandbookOperation { NSString *filePath; NSFileHandle *file; NSURLConnection * […]

iOS:使用应用程序委托来存放全局variables

这是不好的做法,以保存我想要从应用程序委托中的所有类访问的variables,并通过[[UIApplication sharedApplication] delegate] someProperty]

如何在UIMarkupTextPrintFormatter中添加图像?

我正在尝试使用直接的HTML打印文件,但是,我无法将图像添加到打印文件。 如何在我想要打印的HTML中引用项目中的图像? UIMarkupTextPrintFormatter支持标签吗?

iOS,使用下划线vs直接使用iVar

这已经被问了很多,但是这个问题是要得到什么时候你会使用这些方法的例子。 请使用setter和getter无限循环以外的示例 例。 。H – @property(nonatomic, strong)NSMutableArray* mutArray .m – @synthesize mutArray= _mutArray; 1)我想要: _mutArray = [[NSMutableArray alloc] init]; 要么 self.mutArray=[[NSMutableArray alloc] init]; 我为什么要做他们每个人,有什么区别? 2)如果我想添加一个对象… [_mutArray addObject:object]; 要么 [self.mutArray addobject:object]; 为什么? 非常感谢!

iOS从主包复制文件到文件目录

我正在试图将我添加到名为“includes”的文件夹复制到名为“includes”的文档目录中的文件夹。 我得到resContents零值。 为什么? 谢谢 – (void)copyResources{ NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"includes"]; NSString *destPath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"includes"]; NSArray* resContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:sourcePath error:NULL]; for (NSString* obj in resContents){ NSError* error; if (![[NSFileManager defaultManager] copyItemAtPath:[sourcePath stringByAppendingPathComponent:obj] toPath:[destPath stringByAppendingPathComponent:obj] error:&error]) NSLog(@"Error: %@", error);; } }

WKWebView捕获HTTP错误代码

当我从我的页面返回任何http错误(目前401,但我也尝试与404等) http://min60.com/__personal/e401.php WKWebView的委托callback不会返回错误 – (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error – (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error { 如何捕捉这样的错误?

iOS 8启动图像文件 – 导航栏和状态栏

我正在使用Interface Builder为iOS 8创build启动图像文件。我想要的启动图像非常简单(与Settings应用程序相同,我认为) – 导航栏顶部有一个空的分组的TableView。 无标题等 注意,我通常不使用Interface Builder,所以IB对我来说是全新的。 我试图通过添加一个导航栏和表视图到视图 – 然后设置约束。 约束(和颜色)工作正常,但… 问题是 :启动图像在状态栏上全屏显示。 喜欢这个: 我如何获得状态栏和导航栏? 就像我说的,我正在使用默认的“UIView”,当你select在Xcode中添加一个启动屏幕。 所以没有导航控制器; 是这个问题吗? 另外,在UIView上有一些选项, 好像他们应该给我我想要的: 我试着玩状态栏选项,但它不工作。 我需要推断还是默认? 我看到启动图像(状态栏+导航栏)和实际的应用程序运行之间的小偏移,我刚刚定位错误? Top Bar选项的用途是什么? 对于我想要的启动图像,我甚至需要添加一个TableView作为子视图,或者我可以使用主UIView的背景颜色? 我已经尝试过,但后来我得到了与状态栏/导航栏不匹配的颜色… 对于Interface Builder noob,如何创build一个启动屏幕文件来复制设置应用程序的启动屏幕文件?

我怎么知道如果一个UITableView包含特定的NSIndexPath?

这是我正在使用的代码: if (appDelegate.currentMainIndexPath != nil /* && doesPathExistInTableView */) { [tblView scrollToRowAtIndexPath:appDelegate.currentMainIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO]; appDelegate.currentMainIndexPath = nil; }

find一个button的位置。 CGRectMake

我有一个button,我正在使用CGRectMake来像这样定位: btn5.frame = CGRectMake(211, 280, 109, 60); 我猜211和280是button的坐标。 那么如果我想让button靠近左下angular,我该如何修改该代码。

UIImageView旋转animation在触摸的方向

我有一个UIImageView有一个箭头的图像。 当用户点击UIView时,这个箭头应指向保持其位置的水龙头的方向,它应该改变变换。 我已经实现了以下代码。 但它不能按预期工作。 我添加了一个截图。 在这个截图中,当我触摸点左上方的箭头方向应该如图所示。但是这并不是如此。 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch=[[event allTouches]anyObject]; touchedPoint= [touch locationInView:touch.view]; imageViews.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(rangle11)); previousTouchedPoint = touchedPoint ; } – (CGFloat) pointPairToBearingDegrees:(CGPoint)startingPoint secondPoint:(CGPoint) endingPoint { CGPoint originPoint = CGPointMake(endingPoint.x – startingPoint.x, endingPoint.y – startingPoint.y); // get origin point to origin by subtracting end from start float bearingRadians = atan2f(originPoint.y, originPoint.x); […]