天道酬勤,学无止境

swift2

Window title bar appears transparent issue (Not really transparent)

I am trying to make my app have more 'flat' feel so I think it is a good idea to hide the title bar. However, in reality titlebarAppearsTransparent seems only remove the title bar shadow but not make the title bar truly transparent. Before using any code to modify the title bar, After adding the following code (starting have a better feel), self.window?.titlebarAppearsTransparent = true Setting the background color to white, self.window?.backgroundColor = NSColor.whiteColor() self.window?.titlebarAppearsTransparent = true This is certainly not what I want. I thought I just turned the title bar

2022-01-16 17:04:35    分类:问答    swift   macos   cocoa   swift2

使用 swift 2.0 在 ios 开发中未显示 tableview 单元格分隔线。 代码 7(tableview Cell separator line not showing in ios development using swift 2.0. xcode 7)

问题 我正在尝试制作一个包含 tableview 的 ios 应用程序。 当我使用 xcode 7.0.1 进行开发时,它显示了 tableview 单元格分隔线黑色细线。 在我用 Xcode 7.1.1 更新后,它没有显示单元格分隔线。 我尝试了 3 件事,例如 - 尝试了 xcode 右侧面板中的所有设置以显示单元格分隔线。 尝试使用 DidLoad 方法中的代码设置细胞系分离器也创建新的 SingleViewApp,因为它也不会出现。 没有什么能解决问题。 我相信它在 xcode 7.1.1 中的错误或者我在 xcode 中做了一些错误的全局设置,因为对于新应用程序也没有显示。 请建议我一些解决方案。 回答1 当您的模拟器缩放到 50% 时,这可能是一个错误。 我将模拟器窗口缩放到 75% (CMD+2) 或 100% (CMD+1),这似乎显示了分隔线。

2022-01-16 12:51:42    分类:技术分享    uitableview   swift2   xcode7   xcode7.1

如何快速打开/关闭 iPhone 相机闪光灯 2?(How to turn the iPhone camera flash on/off swift 2?)

问题 我正在寻找如何打开/关闭 iPhone 的相机闪光灯,我发现了这个: @IBAction func didTouchFlashButton(sender: AnyObject) { let avDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) // check if the device has torch if avDevice.hasTorch { // lock your device for configuration avDevice.lockForConfiguration(nil) // check if your torchMode is on or off. If on turns it off otherwise turns it on if avDevice.torchActive { avDevice.torchMode = AVCaptureTorchMode.Off } else { // sets the torch intensity to 100% avDevice.setTorchModeOnWithLevel(1.0, error: nil) } // unlock your device avDevice

2022-01-16 07:18:28    分类:技术分享    ios   iphone   flash   swift2

tableview Cell separator line not showing in ios development using swift 2.0. xcode 7

I am trying to make an ios app which has tableview in it. When I was developing using xcode 7.0.1 it was showing tableview cells separator line Black thin line. After I updated with Xcode 7.1.1 , its not showing cell separator lines. I tried 3 things like - Tried All the settings in the right panel of xcode to show cell separator line. Tried setting up the Cell Line Separator using code in DidLoad method creating new SingleViewApp as well, in that also its not coming. Nothing solves the issue. I believe either its bug in xcode 7.1.1 or I am done some wrong global settings in xcode, Because for

2022-01-16 06:44:57    分类:问答    uitableview   swift2   xcode7   xcode7.1

How to turn the iPhone camera flash on/off swift 2?

I was looking how to turn on/off the iPhone's camera flash and I found this: @IBAction func didTouchFlashButton(sender: AnyObject) { let avDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) // check if the device has torch if avDevice.hasTorch { // lock your device for configuration avDevice.lockForConfiguration(nil) // check if your torchMode is on or off. If on turns it off otherwise turns it on if avDevice.torchActive { avDevice.torchMode = AVCaptureTorchMode.Off } else { // sets the torch intensity to 100% avDevice.setTorchModeOnWithLevel(1.0, error: nil) } // unlock

2022-01-16 03:55:38    分类:问答    ios   iphone   flash   swift2

swift 2中sort和sortInPlace之间的区别?(Difference between sort and sortInPlace in swift 2?)

问题 我一直在尝试快速使用 sortInPlace 函数,但它不起作用。 当我使用 sort 函数而不是 sortinplace 时,它​​可以工作。 请解释这两个功能之间的区别。 如果您可以提供小代码示例来演示这两个函数的使用,那将非常有帮助。 回答1 var mutableArray = [19, 7, 8, 45, 34] // function sort sorts the array but does not change it. Also it has return mutableArray.sort() mutableArray // prints 19, 7, 8, 45, 34 // function sortInPlace will mutate the array. Do not have return mutableArray.sortInPlace() mutableArray // prints 7, 8, 19, 34, 45 回答2 FWIW,在 Swift 3 中没有sortInPlace 。 相反,有一个sort & sorted 。 var mutableArray = [19, 7, 8, 45, 34] mutableArray.sortInPlace() // error : 'sortInPlace()' has been

2022-01-16 02:35:53    分类:技术分享    swift   swift2

Difference between sort and sortInPlace in swift 2?

I have been trying to use the sortInPlace function in swift but it is not working. When I use the sort function instead of sortinplace it works. Please explain the difference between these 2 function. It would be very helpful if you can provide small code sample demonstrating the use of both functions.

2022-01-15 23:28:45    分类:问答    swift   swift2

Swift 2 调用中的额外参数“错误”(Swift 2 Extra argument ' error' in call)

问题 嗨,我正在使用 Xcode 7 将我的项目从 Swift 更新到 Swift2,我收到了这个 CoreData 错误: Extra argument 'error' in call 在这一行 if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil { 编辑 这是我的代码: lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = { // The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions that could cause the creation of the store to fail. //

2022-01-15 09:05:35    分类:技术分享    ios   xcode   swift2   xcode7

Swift 2 Extra argument ' error' in call

Hi i'm updating my project from Swift to Swift2 with Xcode 7 and i'm getting this CoreData error : Extra argument 'error' in call in this line if coordinator!.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error) == nil { EDIT this is my code: lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator? = { // The persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. This property is optional since there are legitimate error conditions

2022-01-15 07:23:36    分类:问答    ios   xcode   swift2   xcode7

更改 TableViewCell 内的 UIPageControl 的 CurrentPage 时出现问题(issue while changing the CurrentPage of UIPageControl which is Inside a TableViewCell)

问题 我正在尝试在 tableViewCell 内创建一个轮播,并且几乎就在那里,但是在我的 TableView 中实现 UIPageControl 时遇到了困难,因此当 CollectionViewCell(在 tableViewCell 内)项目发生更改时,我可以在 UIPageControl 上显示它, 我尝试了下面的解决方案并遇到了一个奇怪的行为(可能只有我才奇怪),当视图加载并且我更改了我的item (在 collectionViewCell 中)时,PageControl 的 currentPage 没有改变,但是在向下滚动到 tableView 的末尾并且回到顶部它的工作正常, 假设您有 6 行并且向下滚动到第 6 行,然后当您向上滚动到第 5 行并更改其项目时 pageControl 将起作用,如果您继续这样做直到到达顶部它会正常工作但如果您去从第 5 行到第 6 行并更改第 6 行的项目然后它不起作用 我在cellForRowAtIndexPath初始化我的pageControl : pagerControll = cell.pageControll 然后尝试通过监听 ScrollView 的 contentOffSet 来改变位置 override func scrollViewDidEndDecelerating(scrollView

2022-01-14 18:43:45    分类:技术分享    ios   swift   swift2   uicollectionview   uipagecontrol