Tag: xcode6

我怎样才能以编程方式findSwift的版本?

我知道我可以find我正在运行的Swift的版本,恢复到terminal,input: xcrun swift –version Swift version 1.1 (swift-600.0.57.4) Target: x86_64-apple-darwin13.4.0 另外,我一直在阅读有关Swift中的预处理器macros ,但没有find一个Swift版本常量的运气。 正如Swift 1.2的方法,它将是很好的标志只能运行在Swift 1.1(Xcode高达6.2)或需要Xcode 6.3(Swift 1.2)的新代码的旧代码, 注意:我也可以使用system()来做类似的事情: system("xcrun swift –version | grep version > somefile.txt") 然后打开somefile.txt,而宁愿更简单的解决scheme

Swift – 如何将两个视图控制器链接到一个容器视图,并使用分段控制在它们之间切换?

现在我有一个视图控制器包含1个分段控制和2个UI视图。 但是我认为更新用户界面视图来增强未来的编辑过于复杂。 我正在使用隐藏的方法。 import UIKit class PopularHistoryViewController: UIViewController { @IBOutlet weak var segmentedControl: UISegmentedControl! @IBOutlet weak var popularView: UIView! @IBOutlet weak var historyView: UIView! @IBAction func indexChanged(sender: UISegmentedControl) { switch segmentedControl.selectedSegmentIndex { case 0: NSLog("Popular selected") //show popular view popularView.hidden = false historyView.hidden = true case 1: NSLog("History selected") //show history view popularView.hidden = true […]

didReceiveRemoteNotification不在后台工作

我正在开发一个有大量遗留代码的大型应用程序。 目前 – 有一个实施: – (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 问题是只有当应用程序处于前台时才会调用它,或者当应用程序在后台时用户点击通知。 我试图实现: – (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 但该应用程序的行为相同。 在任何情况下 – 当应用程序在后台时不会调用此方法。 可能是什么问题呢?

默认的标签栏项目颜色使用Swift Xcode 6

环境: – Xcode 6testing版4 – Swift语言 – iOS选项卡式应用程序(默认xCode项目) 如何将标签的默认灰色更改为其他内容? (最好全球) 至于我的研究,我需要以某种方式改变每个选项卡的图像呈现模式原始呈现模式,但我不知道如何

以编程方式导航到另一个视图控制器/场景

在从第一个视图控制器导航到第二个视图控制器时,我收到了一条错误消息。 我的编码是这样的 let vc = LoginViewController(nibName: "LoginViewController", bundle: nil) self.navigationController?.pushViewController(vc, animated: true) 问题是我总是得到这种错误信息 2014-12-09 16:51:08.219 XXXXX[1351:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/FDC7AA0A-4F61-47E7-955B-EE559ECC06A2/XXXXX.app> (loaded)' with name 'LoginViewController'' *** First throw call stack: (0x2efcaf0b 0x39761ce7 0x2efcae4d 0x31b693f9 0x31ac1eaf 0x3191e365 0x317fe895 0x318a930d 0x318a9223 0x318a8801 0x318a8529 0x318a8299 0x318a8231 […]

如何在Swift中设置UIButton背景色forState:UIControlState.Highlighted

我可以设置一个button的背景颜色,但我不知道如何设置UIControlState.Highlighted的背景颜色。 这甚至有可能吗? 或者我需要沿着setBackgroundImagepath?

UITableViewCell的字幕不会更新

今天我开始准备iOS8的应用程序。 我发现我的UITableCells的字幕不会在viewWillAppear内更新。 我把它归结为一个最小的例子: 我有一个静态单元格TableViewController与2个单元格(样式=副标题)一个字幕是空的另一个设置。 我更新这样的字幕: – (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[self.without detailTextLabel] setText:@"foobar"]; [[self.with detailTextLabel] setText:@"barfoo"]; } 虽然everythin在iOS7(和6和5)下工作,但iOS8不会更新第一个单元格的标题。 但是,当我触摸单元格时,它将更新并显示文本。 这是一个模拟器的问题? 一个错误? 难道我做错了什么?

在Interface Builder中使用generics类作为自定义视图

我有一个UIButton的自定义子类: import UIKit @IBDesignable class MyButton: UIButton { var array : [String]? } 这是IBDesignable,我已经将它设置为我的故事板中button之一的自定义类。 我想使它通用,使数组不必是一个string对象。 所以,我试过这个: import UIKit @IBDesignable class MyButton<T>: UIButton { var array : [T]? } 但是,我不确定如何将此设置为IB中的类。 我试着把MyButton<String>或MyButton<Int> ,但接口生成器只是删除尖括号部分,并得到以下编译错误: Command /Applications/Xcode6-Beta4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254 有没有办法使用通用的自定义类,或者不支持?

在iOS 8 UITableView的XCode 6 iPhone模拟器上删除SeparatorInset

我在XCode 6 GM上的UITableView for iPhone 6 Simulator (iOS 8)上发现了一个奇怪的空白区域。 我已经尝试从故事板和代码都设置SeparatorInset ,但白色空间是直到那里。 以下代码适用于iOS 7,但不适用于iOS 8(iPhone 6模拟器)。 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ if ([tableView respondsToSelector:@selector(setSeparatorInset:)]) { [tableView setSeparatorInset:UIEdgeInsetsZero]; } } 我附上下面的截图: 顺便说一句,我正在使用AutoLayout。 我希望有人可以告诉我一个方法来删除TableView上奇怪的空白。

在每次运行之后,Xcode 6都会在iOS8模拟器中重命名我的应用程序的目录。

我正在运行Xcode 6 Beta 5,但自从第一次testing以来,这种情况一直在发生。 模拟器中我的应用程序目录在每次运行后不断重命名。 我花了一段时间才弄明白这一点。 我正在使用它来获取文档的目录参考。 NSString *folder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; NSLog(@"Documents Dir: %@",folder); 现在例如在第一次运行它将是: / Users / Joey / Library / Developer / CoreSimulator / Devices / 5B9930EE-A9B4-4B36-BABB-AA864ACAF2DE / data / Containers / Data / Application / 4B10C2E4-A5C3-4C64-93B1-4069FCCB9C46 / Documents 第二次运行现在是: / Users / Joey / Library / Developer / CoreSimulator […]