Tag: 迅速

UIPickerView的“重用视图”始终为零

在我的程序中,我有与UIPickerView的每一行附加的自定义视图。 但重复使用视图始终是零。 因此,每次创build新的自定义视图对象时。 我怎样才能使用“重用视图”? func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { if let vv = view { return vv // This will never getting called } let rowSize = pickerView.rowSize(forComponent: component) let pickerContentView = PickerContentView(frame: CGRect(x: 0, y: 0, width: rowSize.width, height: rowSize.height)) pickerContentView.titleText = (items[Array(items.keys)[component]]! […]

在Swift中控制器之间的Coredata对象

我将ViewcontrollerA中的Article对象传递给ViewcontrollerB。 但是输出是不同的。 我无法弄清楚为什么实体在ViewcontrollerB中为null。 我用以下代码在两个控制器中打印Article对象。 print(String(describing:listOfArticles)) 产量 ViewcontrollerA。 <Article: 0x600000281810> (entity: Article; id: 0xd00000000168001c <x-coredata://949275DD-E091-49E8-A0D0-2C362B616F97/Article/p90> ; data: <fault>) ViewcontrollerB。 Optional(<Article: 0x600000283610> (entity: <null>; id: 0xd0000000000c0012 <x-coredata://949275DD-E091-49E8-A0D0-2C362B616F97/Article/p3> ; data: <fault>)) 在ViewcontrollerB entity: <null>; 总是空的。 当我尝试使用该对象时,它正在崩溃。 推ViewcontollerA代码: – guard let viewArticelArray = topStories_presenter.fetchAllAritcleForTopStories(fetchedResultsController:fetchedResultsController) else { return } let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "NewsCollectionViewController") as! NewsCollectionViewController vc.listArticle […]

归档不成功,由于错误代码-1,虽然我可以做build立和安装在我的设备与发展概况

我的应用程序使用swift 3和核心数据编码作为离线信息存储。 由于长列表或错误,我无法归档我的应用程序 <unknown>:0: error: no such file or directory: '/Users/Ashwin/Library/Developer /Xcode/DerivedData/BeerScout-eweygxkfdhbkbkalbiyywrsuievg/Build /Intermediates/ArchiveIntermediates/BeerScout/IntermediateBuildFilesPath /BeerScout.build/Release-iphoneos/BeerScout.build/DerivedSources /CoreDataGenerated/BeerScout/Beer+CoreDataClass.swift' … And at last Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 我检查过了 #1 Code optimizations #2 Clean project and derived data #3 Also checked for code-gen for core data files. #4 Revoke and recreate new certificates #5 Cleaning system junks […]

无法用types为'(string:NSString,attributes:)的参数列表调用'subscript'

我有下面的代码,但是当我编译我得到这个错误: “不能用types'(string:NSString,attributes:[NSString:UIFont?])”的参数列表调用'subscript'“。 此代码在xCode 6.0.1上正常工作,但在升级到6.1之后,出现此错误。 let textboldFont = [NSFontAttributeName:UIFont(name: "ProximaNova-Bold", size: 15.0)] let textregularFont = [NSFontAttributeName:UIFont(name: "ProximaNova-Regular", size: 15.0)] let para = NSMutableAttributedString() let attributedstring1 = NSAttributedString(string: dateArray[1] as NSString, attributes:textboldFont)

Swift:编程式embedded标签栏控制器后,导航栏消失

我刚刚编程式embedded一个标签栏控制器到我的应用程序,但它似乎已经强制我的故事板embedded式导航栏消失,我认为这是因为我现在已经设置rootviewController为我的标签栏。 我读这个post的答案,因为它似乎是类似的问题,但这样做会提示我的错误Pushing a navigation controller is not supported 下面是我的代码写在AppDelegate,在这里我创build我的标签视图和导航控制器推到根视图控制器: // Set up the tab and navigation bar controllers var currController = window?.rootViewController let chatSB = UIStoryboard(name: "Chat", bundle: nil) let mainSB = UIStoryboard(name: "Main", bundle: nil) let tabBarController = UITabBarController() var navigationController = UINavigationController(rootViewController: currController!) let profileVC = mainSB.instantiateViewControllerWithIdentifier("profileVC") as TimelineTableViewController let chatVC = chatSB.instantiateViewControllerWithIdentifier("chatInboxVC") […]

无法让UITableViewControllerdynamic填充

我正在关注如何填充表视图的一些基本教程。 我已经成功了一个UITableView和dynamic填充,但以下相同的步骤是不适合我的UITableViewController。 有什么解释为什么我与控制器有困难? 在UITableViewController中没有像UITableView那样多的信息。 有没有一个原因,为什么每个人似乎都倾向于UITableView? 为了logging,这里是我所遵循的教程: http : //www.ioscreator.com/tutorials/tableview-tutorial-in-ios8-with-swift import UIKit class TestTableViewController: UITableViewController, UITableViewDelegate { let tableData = ["One", "Two", "Three"] override func viewDidLoad() { super.viewDidLoad() // Uncomment the following line to preserve selection between presentations // self.clearsSelectionOnViewWillAppear = false // Uncomment the following line to display an Edit button in the navigation bar […]

我查询过后,可以操作FDatasnapshot吗?

我希望能够在Datasnapshot上进行一些自定义过滤。 我不认为我可以创build一个复杂的查询来完成我想要的结果。 这是可能的,如果是这样,parsing快照的最佳方法是什么? 编辑: 我正在使用SwiftyJSON,这是我最终parsing它: standbyRef.observeSingleEventOfType(.Value, withBlock: { snapshot in // do some stuff once println(snapshot.value) self.parseJson(snapshot.value as NSDictionary) }) func parseJson(var snapshot:NSDictionary!){ let json = JSON(snapshot) for (key: String, subJson: JSON) in json { // key to standby users println(key) // one object at a time println(subJson) } }

如何快速比较颜色

我想要为不同的状态更改button背景。 我这样做: @IBAction func addToShedulerAction(sender: UIButton) { println(sender.backgroundColor) if sender.backgroundColor==UIColor.redColor(){ sender.backgroundColor==UIColor.whiteColor() } else //if sender.backgroundColor==UIColor.whiteColor() { sender.backgroundColor=UIColor.redColor() } } 但在第一次按下println时打印nil和背景变成红色,在第二次按下println时打印“可选(UIDeviceRGBColorSpace 1 0 0 1)”,颜色不变

与GoogleMobileAds sdk的奇怪行为

当我把这个方法放在application(_ application: UIApplication, didFinishLaunchingWithOptions GADMobileAds.configure(withApplicationID: "MYAPPID") 我的广告按预期显示。 但是,只要将GADMobileAds.configure(withApplicationID: "MYAPPID")到位于库框架内的辅助方法,并调用该辅助方法,广告就不会显示出来。 而且我可以告诉控制台中没有logging表明什么是错误的。 有谁知道这是为什么?

iOS Swift:跟踪和存储数组中所有重复值的索引?

我最近问了这个问题: iOS Swift:如何存储数组中所有重复值的索引? 我提供了我的问题的确切答案,但我发现我不能用它来实现我的代码中需要的东西。 我试图存储一个Date数组的任何重复值的所有索引,并存储在另一个数组[ [Int] ] 。 例如,这是我的Date数组: let dates = [2016-01-02 08:00:00 +0000, 2016-01-02 08:00:00 +0000, 2016-02-02 08:00:00 +0000, 2016-03-02 08:00:00 +0000, 2016-05-01 08:00:00 +0000, 2016-05-01 08:00:00 +0000] 我想要做的,类似于我以前的问题是将所有重复的Date值的所有索引存储到一个单独的数组。 例如,以下数组将包含: repeatedIndices = [ [0, 1], [2], [3], [4, 5] ] 其中指数0和1包含重复date2016-01-02 08:00:00 +0000和指数4和5包含重复date2016-05-01 08:00:00 +0000 。 我以前的问题有一个答案,它提供了一个[ String: [Int] ] ,并作为一个初学者,我不知道如何操作它来处理我的代码,因为字典是无序的 ,我需要一个有序的数组。 如果有必要,请标记为重复,但我不想编辑问题,并取消标记答案,因为这是不公平的。 […]