Tag: swift

在UIPickerView问题中select第一行

我有一个很多的文本toolBar和pickerView与工具toolBar ,它有一个done button 。 我的问题是我不能从select器中select第一行。 虽然我在didSelectRow中进行了debugging,但是它不会在里面运行。 那么请问哪里是我的问题? func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { var value = currentPickerArray[row] textFieldOutletArray[currentTag].text = value }

UIPickerView使用NSDictionary

我是Swift编程语言的新手。 我正在尝试使一个UIPickerView工作像select或列表框中包含键,value.If用户从select器视图中select一个,它给了我的价值的关键。 我一直在浏览几乎一半的时间试图找出这一点。 我得到的是UIPickerView使用数组results.All我想知道是如何在UIPickerView存储Dictionary [key:value],如果用户从UIPickerViewselect一个值,如何获得密钥。 请帮忙。 带着敬意

滚动视图大小与Autolayout:框架是紧凑型/任何尺寸的类600×480,大于iphone5?

我希望我的scrollview的框架与superview框架的大小相同。 并设置contentize,使其包含所有的imageViews。 问题是与AutoLayout,宽度和高度是600×480,我使用的iPhone5和尺寸类是W:紧凑/小时:任何。(我期望像这样的:320×523)。 我的约束是:与超视图相等的宽度,与超视图(乘法器0.8)相等的高度,水平中心X和垂直中心Y. let pagesScrollViewSize = scrollView.frame.size println("pagesScrollViewSize : \(pagesScrollViewSize)") //600×480 scrollView.contentSize = CGSizeMake(pagesScrollViewSize.width * CGFloat(pageCount), pagesScrollViewSize.height) 会有人知道如何解决这个问题吗? imageview显示比屏幕的框架更大,所以.SizeAspectFit不符合正确的尺寸。 而不是滚动到另一个imageView,它滚动查看图像的其余部分,我不想要的。 编辑: 这是ViewController.swift中的整个代码: class ViewController: UIViewController, UIScrollViewDelegate { @IBOutlet weak var pageControl: UIPageControl! @IBOutlet weak var scrollView: UIScrollView! var pageViews: [UIImageView?] = [] var pageImages : [UIImage?] = [] override func viewDidLoad() { super.viewDidLoad() pageImages […]

Swift:“mapView.showUserLocation = true”返回“致命错误:意外地发现零,而解包可选值(lldb)”

所以我试图用“bar”或“pizza”这样的关键词来searchSwift中的本地商家。 我将search链接到一个button动作,以便位置将在定义的区域内的地图上popup。 但是,我甚至不能让应用程序加载用户位置,因为我得到一个零错误。 这是我的AppDelegate: import UIKit import CoreLocation @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? var locationManager: CLLocationManager? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. locationManager = CLLocationManager() locationManager?.requestWhenInUseAuthorization() return true } func applicationWillResignActive(application: UIApplication) { // Sent when the application is […]

尝试从iOS连接到Meteor时握手错误9806

我想在我的Swift应用程序中使用名为ObjectiveDDP的库。 我可以像这样连接到示例应用程序: var meteorClient = initialiseMeteor("pre2", "wss://ddptester.meteor.com/websocket"); 当我试图连接到我的本地meteor服务器,我得到这个错误:CFNetwork SSLHandshake失败(-9806) 我在模拟器上运行iOS 8.1。 任何想法我失踪? 任何帮助,将不胜感激。

GPUImage swift iOS 7

有人用Swift和GPUImage为iOS 7+发布了应用程序吗? 当我试图发布一个应用程序,我得到错误(这不是我的屏幕,但我得到相同的) 应用程序在ios 7的所有设备和模拟器上都非常完美,我也通过testflight将其作为adhoc发送,并且仍然可以工作,但是现在我无法发布。

UIImageView在表视图中不显示,直到点击或设备是roatated

我正在学习swift / IOS的​​过程中,并有一个问题,获取图像显示在表视图单元格中,当imageView设置在传递给dispatch_async(dispatch_get_main_que)的闭包内。 这是我的代码返回tableview的单元格。 注意,调度调用被注释掉了。 在这种状态下,一切都好。 (图像没有任何交互显示) override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell: UITableViewCell if indexPath.section == 3 { cell = tableView.dequeueReusableCellWithIdentifier("imageCell", forIndexPath: indexPath) as! MentionedImageTableViewCell if let images = tweetSections?[3].items as? [MediaItem] { let imageUrl = images[indexPath.row].url let qos = Int(QOS_CLASS_USER_INTERACTIVE.value) let queue = dispatch_get_global_queue(qos, 0) println("feching image […]

WatchKit Image Animation等待完成

我目前正在寻找一种方法来等待完成我的图像animation,然后在完成后开始下一个。 我想用一个完成处理程序,但它“不适合我”是否有办法在这种情况下使用它? if X > 1 { self.GroupIMG.setBackgroundImageNamed("single") self.GroupIMG.startAnimatingWithImagesInRange(NSRange(location: 0, length: 300), duration: Repeater, repeatCount: self.X) } //this should start after the if is done self.GroupIMG.setBackgroundImageNamed("single") self.GroupIMG.startAnimatingWithImagesInRange(NSRange(location: 0, length: leftX), duration: Repeater, repeatCount: 1)

提出问题,同时使用swift从JSON中获取数据

我正在使用swift从JSON中检索数据。 我是JSON的新手。 我不怎么检索这个嵌套的值。 我的JSON格式如下。 //JSON DATA { "data": [ { "category_id": 1, "category_name": "category1", "category_icon": "", "category_child": [ { "sub_category_id": 11, "sub_category_name": "subcategoryname1", "sub_category_icon": "" }, { "sub_category_id": 12, "sub_category_name": "subcategoryname2", "sub_category_icon": "" } ] }, { "category_id": 2, "category_name": "category2", "category_icon": "", "category_child": [ { "sub_category_id": 21, "sub_category_name": "subcategoryname12", "sub_category_icon": "" }, { "sub_category_id": […]

在Swift中将Int更改为CGFloat以返回heightForRowAtIndexPath tableview函数

我相信我错过了一些非常简单的东西,但我却无法让它工作。 如果他们有同样的问题,我会试着更好地解释我正在做什么来帮助别人。 这是我的function: func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return (count * 40 + 75) as CGFloat } 上述function不起作用。 感谢我收到的帮助,我发现这是做到这一点的方法: func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return CGFloat(count * 40 + 75) } 谢谢!