swift3

AVPlayerViewController doesn't play local videos

家住魔仙堡 提交于 2019-12-31 05:18:47
问题 I have added a DemoVideo.mp4 in my project and added it to copy resource file. But when i run the app it doesn't play my video. Here is my method. private func setUpAndPlayVideo() { guard let videoPath = Bundle.main.path(forResource: "DemoVideo.mp4", ofType: nil) else { return } let videoURL = NSURL(string: videoPath) let player = AVPlayer(url: videoURL! as URL) playerViewController = AVPlayerViewController() playerViewController.player = player playerViewController.view.frame = self

swift 3 - create entry with relationship

耗尽温柔 提交于 2019-12-31 04:56:10
问题 i working the first time with relationships in core data. what i have now: let appdelegate = NSApplication.shared().delegate as! AppDelegate let context = appdelegate.persistentContainer.viewContext // Create Person let entityPerson = NSEntityDescription.entity(forEntityName: "Person", in: context) let newPerson = NSManagedObject(entity: entityPerson!, insertInto: context) newPerson.setValue("Max", forKey: "name") // Create Book let entityBooks = NSEntityDescription.entity(forEntityName:

Pass data back to previous VC using delegates and update custom cell

自古美人都是妖i 提交于 2019-12-31 04:45:08
问题 I am trying to pass data BACK to the previous viewController using delegates. Does anyone know how to pass data back from ViewController B to ViewController A ? So I want to pass data from SecondVC to FirstVC and update custom table view cells with the data from SecondVC 4 address text fields but for some reason, it's not updating at all. Any help will be much appreciated as I'm just at the beginning level so tried all sorts of things but not able to get it to work. FirstVC import UIKit class

Animated iMessage App Graphics

青春壹個敷衍的年華 提交于 2019-12-31 04:09:46
问题 I'm creating my own iMessage Custom App and I simply want to send an iMessage with a background that swaps between 2 images, therefore creating the illusion of animation. I'm not even sure this is possible but I'm trying with the code below. This code only shows the first image when the message is received by the recipient. Any help would be appreciated. func createImageForMessage() -> UIImage? { let cupAnimation = UIImageView(frame: CGRect(x: 0, y: 0, width: 300, height: 300)) let

Getting two different device IDs from same iphone

那年仲夏 提交于 2019-12-31 03:49:05
问题 I am getting different UDIDs for my iphone when i get it from itunes and programatically like this UDID:String = UIDevice.current.identifierForVendor!.uuidString Basically im trying to acquire a unique identifier for my iphone just like we have mac address for android phones. 回答1: one easiest way is to solve this issue by storing the identifierForVendor in keychain. even if you uninstall app ,value for the key remains same and its unchanged. many third party libraries available to perform

Nil is not compatible with expected argument type Selector

心已入冬 提交于 2019-12-31 03:37:26
问题 In converting from Swift 2.3 to Swift 3, I receive the error above for the following line of code: var contactButton: UIBarButtonItem {return self.CustomRightItem("icon-nav-nls-contact", target: self, action: nil)} The problem is on the nil action. I've tried using and empty selector: #selector() and ```#selector(nil) both to no avail. How can I handle a nil action in Swift 3? 回答1: This is clearly placeholder code for a later action, so use a placeholder function where the code will

Keep a view always on top (Don't scroll with keyboard) in IQKeyboardManager

折月煮酒 提交于 2019-12-31 02:58:24
问题 I'm using IQKeyboardManager to keep the text fields to go up after typing with the keyboard. I don't want to scroll to a specific view even when clicked on the text field. Below is the screenshot of the design. I want the 'header' to remain on top. From their documentation, there is a way to keep the navigation bar remain on top. 回答1: Try this. Disable the IQKeyboardManager for your this viewController. for that, IQKeyboardManager.sharedManager().disableInViewControllerClass(your view

Xcode 8 Beta 4 CGColor.components unavailable

烈酒焚心 提交于 2019-12-31 01:48:13
问题 Whilst the code below worked previously, it has stopped working in Xcode 8 Beta 4, presumably because the components return was a very un-Swift-y C-array of floats, and has been removed. The error is bald - "'components' is unavailable" - and I can't find what has replaced it, if anything. Does anyone know how to produce the same functionality? public var cgColour: CGColor { get { return CGColor(red: self.colourRed, green: self.colourGreen, blue: self.colourBlue, alpha: self.colourAlpha) }

Trying to Reload FSCalendar with JSon data but it crashes

我是研究僧i 提交于 2019-12-30 13:33:03
问题 this question is linked with the my previous account's question. How to make API call for this web service to fetch array of present and absent dates separately in swift? code import UIKit import FSCalendar class AttendenceViewController : UIViewController, FSCalendarDelegate, FSCalendarDataSource, FSCalendarDelegateAppearance { @IBOutlet weak var calendar: FSCalendar! var presentdays : Array = [String]() var absentdays : Array = [String]() fileprivate let gregorian: Calendar = Calendar

Trying to Reload FSCalendar with JSon data but it crashes

一笑奈何 提交于 2019-12-30 13:32:11
问题 this question is linked with the my previous account's question. How to make API call for this web service to fetch array of present and absent dates separately in swift? code import UIKit import FSCalendar class AttendenceViewController : UIViewController, FSCalendarDelegate, FSCalendarDataSource, FSCalendarDelegateAppearance { @IBOutlet weak var calendar: FSCalendar! var presentdays : Array = [String]() var absentdays : Array = [String]() fileprivate let gregorian: Calendar = Calendar