Tag: swift

在TableViewCell里面的UICollectionView没有被调用

我有一个UITableView包含一个水平滚动UICollectionView在这样的每个单元格 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ServiceTypeCell cell.collectionView.delegate = self cell.collectionView.dataSource = self cell.lblName.text = serviceTypes[indexPath.row].name cell.tag = getTag(indexPath) print("uitableviewcell : \(indexPath)") return cell } 并在每个UICollectionViews func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection […]

如何在滚动tableview后点击select行来修复崩溃?

我有这样的表格视图: 当用户点击一行时,我想取消选中最后一行并检查选中的行。 所以我这样写我的代码:(例如我的lastselected = 0) func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { var lastIndexPath:NSIndexPath = NSIndexPath(forRow: lastSelected, inSection: 0) var lastCell = self.diceFaceTable.cellForRowAtIndexPath(lastIndexPath) as! TableViewCell var cell = self.diceFaceTable.cellForRowAtIndexPath(indexPath) as! TableViewCell lastCell.checkImg.image = UIImage(named: "uncheck") cell.checkImg.image = UIImage(named: "check") lastSelected = indexPath.row } 当我点击一行而不滚动时,每件事情都很好。 我意识到,当我运行的代码和滚动表立即select了一行。 我的程序会崩溃,错误:“致命错误:意外地发现零,而解包可选值” 错误显示在这一行: 我不知道这里有什么错

iOS Facebook SDK 4会话

我遇到了iOS的新FacebookSDK的问题。 我可以成功login并获取必要的信息,但是当我再次打开我的应用程序时,我打算跳过login过程,正在validation的会话为空。 这是我的AppDelegate: class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { self.window = UIWindow(frame: UIScreen.mainScreen().bounds) self.window!.rootViewController = LogInViewController() self.window!.makeKeyAndVisible() FBSDKProfile.enableUpdatesOnAccessTokenChange(true) return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) } func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: […]

Swift(beta 3)“NSDictionary? 不符合协议“可衡量”“

自从更新到最新的Xcode 6 DP3以来,我在Swift代码中已经有了一些警告和错误。 大多数已经通过采用新改变的语法来解决,但是有一个似乎很奇怪的错误。 下面的代码给出错误Type 'NSDictionary?' does not conform to protocol 'Equatable' Type 'NSDictionary?' does not conform to protocol 'Equatable' : if (launchOptions != nil && launchOptions![UIApplicationLaunchOptionsRemoteNotificationKey] != nil) { 有没有人有办法解决吗? 我可能忽略这里简单的东西..! 谢谢

在swift 2.0中一次显示文本一个字符

新的Swift 2.0; 试图学习它,对animation感兴趣,并试图编写一些代码在屏幕上一次显示一个字符的消息。 我写这个,它的工作原理,但我忍不住,但我可以不用CALayers和/或alpha值做什么? 或者是一些有生气的小玩意儿,更值得一提的东西; 这感觉看起来有点笨重,真的很像1977年。 import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let supertext = "A long time ago, in a galaxy far, far away …" let round = supertext.characters.count for i in 0…round { let delay […]

强制collectionView只有2行

我必须做一个集合视图,以便不考虑iPhone的大小,我们每行只有2个图像,我们也需要每行和每列之间的边界,如图所示。 我想要这样:

的UIWindow? 没有名为bounds的成员

我试图更新PKHUD( https://github.com/pkluz/PKHUD )与Xcode 6testing版5一起工作,几乎通过除了一个微小的细节: internal class Window: UIWindow { required internal init(coder aDecoder: NSCoder!) { super.init(coder: aDecoder) } internal let frameView: FrameView internal init(frameView: FrameView = FrameView()) { self.frameView = frameView // this is the line that bombs super.init(frame: UIApplication.sharedApplication().delegate.window!.bounds) rootViewController = WindowRootViewController() windowLevel = UIWindowLevelNormal + 1.0 backgroundColor = UIColor.clearColor() addSubview(backgroundView) addSubview(frameView) } // […]

迭代所有的UITableCells给出一个部分ID

我如何迭代所有的UITableCells给出一个部分ID(例如:第2节中的所有单元格)? 我只看到这个方法: tableView.cellForRowAtIndexPath ,它返回给定的绝对索引1单元格,所以它没有帮助。 有没有一个优雅和简单的方法? 注意:我想以段落中的所有单元格为单位设置AccesoryType为None,例如:在单击button之后,或者在发生事件之后(发生什么事情与问题无关) 我有UITableView的参考和部分的索引。

UIActivityViewController在Swift崩溃在iPad上

我在我的游戏中做了一个共享function,我有代码,它在iPhone上工作正常,但是当我在iPad上testing时,当我点击分享button时,应用程序崩溃。 我正在使用共享button下面的代码 let textToShare = "Check out this website!" if let myWebsite = NSURL(string: "http://www.apple.com/") { let objectsToShare = [textToShare, myWebsite] let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil) self.view?.window?.rootViewController?.presentViewController(activityVC, animated: true, completion: nil) }

没有这样的模块“FBSDKCoreKit”XCODE 7.4

我正在尝试使用FBSDKCoreKit和FBSDKLogin添加Facebookloginfunction。 当我尝试将这两个框架导入到我的AppDelegate文件时,它显示错误 “没有这样的模块”FBSDKCoreKit“”。 我将“ Allow Non-modular Includes In Framework Modules从NO更改为YES ,但错误仍然存​​在。 我需要帮助提出一个解决scheme来解决这个错误。