Questions tagged «ios»

iOS是在Apple iPhone,iPod touch和iPad上运行的移动操作系统。使用此标签[ios]来解决与iOS平台上的编程有关的问题。使用相关的标签[objective-c]和[swift]解决那些编程语言所特有的问题。

11
更改按钮中png的颜色-iOS
我有一组创建的图标,它们是透明的白色PNG: 而我想做的就是能够将它们着色为其他颜色。例如蓝色,灰色等 我注意到,“单击/点击”它们会自动变为灰色。因此,我想我可以通过点击或将其正常状态更改为我喜欢的灰色: 实现这一目标的最佳方法是什么?
93 ios  swift 

11
从Swift函数中的异步调用返回数据
我已经在我的Swift项目中创建了一个实用程序类,用于处理所有REST请求和响应。我建立了一个简单的REST API,因此可以测试我的代码。我创建了一个需要返回NSArray的类方法,但是由于API调用是异步的,因此我需要从异步调用内的方法中返回。问题是异步返回void。如果我在Node上执行此操作,则将使用JS promises,但我找不到能在Swift中使用的解决方案。 import Foundation class Bookshop { class func getGenres() -> NSArray { println("Hello inside getGenres") let urlPath = "http://creative.coventry.ac.uk/~bookshop/v1.1/index.php/genre/list" println(urlPath) let url: NSURL = NSURL(string: urlPath) let session = NSURLSession.sharedSession() var resultsArray:NSArray! let task = session.dataTaskWithURL(url, completionHandler: {data, response, error -> Void in println("Task completed") if(error) { println(error.localizedDescription) …
93 ios  rest  asynchronous  swift 

15
Swift中的“使用未解决的标识符”
因此,我一直在开发一个应用程序,并且一切正常。但是今天我像往常一样创建了一个新类,由于某种原因,我不能从其他类中访问Public / Global变量。所有其他班级都可以,但是现在无论何时我尝试开设一个新班级我都做不到。如何解决? 我正在使用Swift和Xcode 6。 工人阶级: import UIKit import Foundation import Parse import CoreData var signedIn = true class ViewController: UIViewController { 新课程: import UIKit class NewClass: UIViewController { override func viewDidLoad() { super.viewDidLoad() signedIn = false } 但是在 signedIn = false 我得到错误: 使用未解决的标识符“ signedIn”
93 ios  xcode  swift 

13
Swift-如何检测方向变化
我想将两个图像添加到单个图像视图中(即用于横向显示一个图像,用于纵向显示另一个图像),但是我不知道如何使用快速语言检测方向变化。 我尝试了这个答案,但只拍了一张图片 override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { if UIDevice.currentDevice().orientation.isLandscape.boolValue { print("Landscape") } else { print("Portrait") } } 我是iOS开发的新手,任何建议将不胜感激!
93 ios  swift 

21
如何在Swift中调整图片大小?
我正在使用Swift和Parse.com为iOS开发应用程序 我试图让用户从图像选择器中选择一张图片,然后将所选图像的大小调整为200x200像素,然后再上传到我的后端。 Parse.com有一个用于Instagram复制应用程序的教程,名为“ AnyPic”,其中提供了用于调整图像大小的代码,但这是在Objective-C中。 // Resize the image to be square (what is shown in the preview) UIImage *resizedImage = [anImage resizedImageWithContentMode:UIViewContentModeScaleAspectFit bounds:CGSizeMake(560.0f, 560.0f) interpolationQuality:kCGInterpolationHigh]; // Create a thumbnail and add a corner radius for use in table views UIImage *thumbnailImage = [anImage thumbnailImage:86.0f transparentBorder:0.0f cornerRadius:10.0f interpolationQuality:kCGInterpolationDefault]; 如何在Swift中为所选图片创建200x200px版本(然后上传)? 而且,thumbnailImage函数在做什么?
93 ios  swift  uiimage 


1
如何确定我的React Native应用是JavaScript代码的调试版本还是发布版本?
我想在我的React Native应用程序中添加一些仅调试的UI,但是在JavaScript环境中找不到任何等效的RCT_DEBUG或RCT_DEV编译时标志。有一个吗? 用例:我想添加一个状态栏,以显示由我的应用程序发起的HTTP请求的数量。显然,这不是运输应用程序的一部分,但可以帮助我在开发和测试时检查我的工作。

4
如何创建UIView跳动动画?
对于名为的UIView finalScoreView,我具有以下CATransition ,这使它从顶部进入屏幕: CATransition *animation = [CATransition animation]; animation.duration = 0.2; animation.type = kCATransitionPush; animation.subtype = kCATransitionFromBottom; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; [gameOver.layer addAnimation:animation forKey:@"changeTextTransition"]; [finalScoreView.layer addAnimation:animation forKey:@"changeTextTransition"]; 我如何使它下降后反弹一次,然后保持静止?它仍然应该从顶部进入屏幕,但是当它下来时会反弹。 任何帮助将不胜感激,谢谢!

23
定位MKMapView以一次显示多个注释
我有几个要添加到我的MKMapView的注释(它可以是0-n个项目,其中n通常约为5)。我可以很好地添加注释,但是我想立即调整地图的大小以适合屏幕上的所有注释,而且我不确定如何执行此操作。 我一直在看,-regionThatFits:但是我不确定该怎么做。我将发布一些代码以显示到目前为止的内容。我认为这应该是一项通常很简单的任务,但到目前为止,我对MapKit感到有些不知所措。 - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{ location = newLocation.coordinate; //One location is obtained.. just zoom to that location MKCoordinateRegion region; region.center = location; //Set Zoom level using Span MKCoordinateSpan span; span.latitudeDelta = 0.015; span.longitudeDelta = 0.015; region.span = span; // Set the region here... but I want …

5
iOS自动布局:两个宽度相等的按钮并排
我目前在使用AutoLayout时遇到困难。我正在使用界面生成器,并试图将两个宽度相等的按钮并排放置,如下图所示。 从下面的预览图像中,我的titleImage已被适当地约束并且可以正确显示,但是按钮却没有。我已经尝试过将button 1与titleImage的前端对齐,将button2与titleImage的后端对齐,但是此时两个按钮之间的宽度分布变得偏斜,如下所示。 我的目标是了解缺少哪些约束,并且无论设备如何,都应将其应用于两个按钮以保持相等的宽度。如果可能的话,我想通过界面生成器来实现,而不是其他代码。
92 ios  iphone  xcode  autolayout 


7
如何使CATextLayer中的文本清晰可见
我CALayer添加CATextLayer了,文本变得模糊。在文档中,他们谈论“亚像素抗锯齿”,但这对我来说意义不大。任何人都有一个代码段,可以使一些CATextLayer清晰的文本成为? 以下是Apple文档中的文字: 注意:渲染文本时,CATextLayer禁用子像素抗锯齿。仅在对文本进行光栅化的同时将其合成到现有的不透明背景中时,才可以使用子像素抗锯齿来绘制文本。在让背景像素将文本像素编织到其中之前,无法单独将子像素抗锯齿的文本单独绘制到图像或图层中。将图层的不透明度属性设置为YES不会更改渲染模式。 第二句话意味着,如果将composites其合并为,则可以得到美观的文本。existing opaque background at the same time that it's rasterized. 那太好了,但是如何合成它,如何赋予它不透明的背景,以及如何对其进行光栅化? 他们在Kiosk菜单示例中使用的代码是这样的:(它是OS X,不是iOS,但我认为它可以工作!) NSInteger i; for (i=0;i<[names count];i++) { CATextLayer *menuItemLayer=[CATextLayer layer]; menuItemLayer.string=[self.names objectAtIndex:i]; menuItemLayer.font=@"Lucida-Grande"; menuItemLayer.fontSize=fontSize; menuItemLayer.foregroundColor=whiteColor; [menuItemLayer addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMaxY relativeTo:@"superlayer" attribute:kCAConstraintMaxY offset:-(i*height+spacing+initialOffset)]]; [menuItemLayer addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMidX relativeTo:@"superlayer" attribute:kCAConstraintMidX]]; [self.menuLayer addSublayer:menuItemLayer]; } // end of for loop 谢谢! …

4
presentViewController:在iOS <6(AutoLayout)上崩溃
这是我遇到的怪异崩溃。当我按下转到某个ViewController的按钮时,发生崩溃。它崩溃的行是: DestinationInformationViewController *info = [[DestinationInformationViewController alloc] init]; [info setModalTransitionStyle: UIModalTransitionStyleCrossDissolve]; [self presentViewController:info animated:YES completion: nil]; // CRASHES HERE [info release]; 崩溃跟踪为: *** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint' *** First throw call stack: (0x3758288f 0x35287259 0x37582789 0x375827ab 0x3153d54d 0x3153d6bb 0x3153d423 0x314ce001 0x3143c3c7 …



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.