Tag: 快速

Firebase将垃圾logging到控制台中。 Xcode – 8(Swift3)

以下是我使用的代码。 任何人都可以帮我解决这个问题吗? AppDelegate.swift import UIKit import CoreData import Firebase @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. FIRApp.configure() return true } …. } ViewController.swift import UIKit import Firebase class ViewController: UIViewController { @IBOutlet var Username: […]

在Swift中检测UIImageView触摸

如何在UIImageView被触摸时检测并执行一个动作? 这是我到目前为止的代码: override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { var touch: UITouch = UITouch() if touch.view == profileImage { println("image touched") } }

在UITableView后面设置渐变

我创build了一个tableViewController我调用这个函数: func setTableViewBackgroundGradient(sender: UITableViewController ,let topColor:UIColor, let bottomColor:UIColor){ let gradientBackgroundColors = [topColor.CGColor, bottomColor.CGColor] let gradientLocations = [0.0,1.0] let gradientLayer = CAGradientLayer() gradientLayer.colors = gradientBackgroundColors gradientLayer.locations = gradientLocations gradientLayer.frame = sender.tableView.bounds sender.tableView.backgroundView?.layer.insertSublayer(gradientLayer, atIndex: 0) } 有: setTableViewBackgroundGradient(self, UIColor(0xF47434), UIColor(0xEE3965)) 但我得到的是这样的:

如何在swift中以编程方式创build自定义视图,并控制文本字段,button等

我正在尝试使用ViewController.swift中的以下代码从另一个类访问MyCustomView .. var view = MyCustomView(frame: CGRectZero) ..在viewDidLoad方法中。 问题是视图不能在模拟器中初始化。 我已经在当前的ViewController的storyboard中设置了类。 class MyCustomView: UIView { var label: UILabel = UILabel() var myNames = ["dipen","laxu","anis","aakash","santosh","raaa","ggdds","house"] override init(){ super.init() } override init(frame: CGRect) { super.init(frame: frame) self.addCustomView() } required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } func addCustomView() { label.frame = CGRectMake(50, 10, 200, 100) […]

使用Apple的Reachability在Swift中检查远程服务器的可达性

我正在开发用Swift编写的iOS应用程序,它与本地networking上的HTTP服务器进行通信,并使用Apple的Reachability类来确定运行HTTP服务器的远程机器是否在线。 代码如下: … let RemoteHost: String = "192.168.178.130" var RemoteReachability: Reachability! = nil var RemoteIsReachable: Bool = false init() { super.init() self.RemoteReachability = Reachability(hostName: self.RemoteHost) NSNotificationCenter.defaultCenter().addObserver(self, selector: "reachabilityChanged:", name: kReachabilityChangedNotification, object: self.RemoteReachability) self.RemoteReachability.startNotifier() self.RemoteIsReachable = (self.RemoteReachability.currentReachabilityStatus().value == ReachableViaWiFi.value) } func reachabilityChanged(notification: NSNotification) { let ReachabilityInst: Reachability = notification.object as Reachability self.RemoteIsReachable = (ReachabilityInst.currentReachabilityStatus().value == ReachableViaWiFi.value) […]

如何在Swift中设置自定义视图的内容大小?

背景 我正在制作一个垂直的标签,用于传统的蒙古文字。 在我刚刚旋转UILabel ,有一些性能问题和其他复杂性。 现在我正在从头开始制作标签。 但是,我需要垂直标签来告诉自动布局当它的高度调整(基于string长度)。 我读过的 我使用内置内容大小文档阅读了内部内容大小和视图 。 但是,这些更多的是关于如何使用它,而不是如何在自定义视图中定义它。 search“自定义视图的ios内在内容大小”只给我 正确使用intrinsicContentSize和sizeThatFits:在具有自动布局的UIView子类上 在堆栈溢出。 这个特定的问题甚至不需要内在的内容大小,因为他们的观点只是一个标准视图的集合。 我正在尝试 我正在尝试的是我的答案。 我添加了这个问答对,这样就不会让其他人花很长时间才能find答案,因为它使用了我使用的search关键字。

Swift – UITableViewCellselect多个select的背景颜色

//Don't Works… cell.selectionStyle = .Blue //Works when the selection is not multiple, if it's multiple with each selection the previos one disappear… let cellBGView = UIView() cellBGView.backgroundColor = UIColor(red: 0, green: 0, blue: 200, alpha: 0.4) cell.selectedBackgroundView = cellBGView 任何答案如何设置所选单元格的背景颜色?

Xcode 8自定义字体不显示在界面生成器中

我想在我的iOS应用程序中使用自定义字体(Bebas Neue)。 我采取的步骤是: 将.otf文件复制到项目。 确认.otf文件已将项目设置为目标。 在plist中添加“应用程序提供的字体”中的.otf文件。 在“构build阶段”中,.otf文件位于“复制包资源”中。 在我的Mac上安装字体。 尝试打印出所有可用的字体,但我看不到我的自定义字体。 我使用的代码: for name in UIFont.familyNames() { println(name) if let nameString = name as? String { println(UIFont.fontNamesForFamilyName(nameString)) } } 试图在代码中设置字体,它的工作。 我使用的代码: textLabel?.font = UIFont(name: "BebasNeueRegular", size: 14) 但是我不能在界面生成器中设置它。 任何想法? 截图:

nw_host_stats_add_src recv太小,收到24,预计28

nw_host_stats_add_src recv too small, received 24, expected 28 所以我得到这个出现在控制台,我不知道这是否是一个问题,我应该打扰或不。 在将我的应用程序附加到Firebase并使用匿名login写入数据库之后,我注意到了这一点。只是想知道我是否需要对此做任何事情,如果是的话,这些操作是什么。 谢谢!

导入Firebase后,Xcode 8.0testing版会发出错误提示

我使用Xcode 8.0 beta 5或6创build空的swift项目,并使用类似Firebase指南的cocoapods导入Firebase。 在import过程中,一切都很好。 我使用FIRApp.Configure()注释来configurationFIRApp.Configure() 。 我可以处理身份validation,但是当我试图达到数据库它不起作用。 在FIRApp.h构build时间错误, FIRApp.h所示: "Conflicting nullability specifier on return types, 'nullable' conflicts with existing specifier 'non null'" FIRApp.h生成时错误的屏幕截图 在控制台中也是这样的错误: 2016-08-26 13:00:32.719: <FIRInstanceID/WARNING> STOP!! Will reset deviceID from memory. 2016-08-26 13:00:32.719: <FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=6 "(null)" 2016-08-26 13:02:08.329: <FIRInstanceID/WARNING> Failed to retrieve the default GCM […]