Posts

Post not yet marked as solved
1 Replies
710 Views
Hey guys, is it possible to use the font facing mac camera from xcode playgrounds in mac? I am trying to access the camera but i am unable to do so. The code works fine in Xcode but not in Xcode playgrounds. My app relies on the front facing camera and also I do not have an iPad to work on this project. This is the code I am using to access the camera:let captureSession = AVCaptureSession() var captureDevice: AVCaptureDevice!func prepareCamera() { captureDevice = AVCaptureDevice.default(for: AVMediaType.video) beginSession() } func beginSession() { do { let input = try AVCaptureDeviceInput(device: captureDevice) captureSession.addInput(input) } catch { } captureSession.beginConfiguration() captureSession.sessionPreset = .vga640x480 let dataOutput = AVCaptureVideoDataOutput() dataOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: Int(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange)] dataOutput.alwaysDiscardsLateVideoFrames = true if captureSession.canAddOutput(dataOutput) { captureSession.addOutput(dataOutput) } captureSession.commitConfiguration() let queue = DispatchQueue(label: "captureQueue") dataOutput.setSampleBufferDelegate(self, queue: queue) captureSession.startRunning() }Any help would be appreciated.
Posted
by Samarth.
Last updated
.
Post not yet marked as solved
1 Replies
544 Views
There are multiple tableviews in my app, but the tableview with fixed cell size have no problem. However, 2 tableviews that I am using have variable cell size and it is causing lag/stuttering(when the cells with greater height value appears). I initially thought thats maybe because my cell is designed very inefficiently. However even simple table view cells with just a textfield(variable height) and a label(fixed height) is causing stuttering.Layout constraints of the cell:1. Label is given a height os 20, pinned 0 from the bottom with 5px trailing and leading2. TextView is pinned 0 from top and 0 to the label below it with 5px trailing and leadingI have tried everything and looked at many articles but I am not able to find any helpful solution. Here is the cell file:import UIKitclass ConvoCell: UITableViewCell { @IBOutlet weak var messageView: UITextView! @IBOutlet weak var BgViewRightContraint: NSLayoutConstraint! @IBOutlet weak var BgViewLeftContraint: NSLayoutConstraint! @IBOutlet weak var TimingInfo: UILabel! @IBOutlet weak var bgView: UIView! override func awakeFromNib() { super.awakeFromNib() // Initialization code } func datainit(message: String, time: String, type: Int32){ self.messageView.text = message self.TimingInfo.text = time if (type == 1){ bgView.backgroundColor = .orange self.messageView.textColor = .white BgViewRightContraint.constant = 5 BgViewLeftContraint.constant = 50 TimingInfo.textColor = .white } else { bgView.backgroundColor = .white self.messageView.textColor = .black self.TimingInfo.textColor = .black BgViewRightContraint.constant = 50 BgViewLeftContraint.constant = 5 } }}Here is the code for my cellForRowAt:func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { guard let cell = tableView.dequeueReusableCell(withIdentifier: "messageBubble") as? ConvoCell else { return UITableViewCell() } cell.selectionStyle = .none messagetable.separatorStyle = .none var currentMessage: Message! currentMessage = chat.fetchedMessages[indexPath.row] cell.datainit(message: currentMessage.body!, time: currentMessage.timingInfo!, type: currentMessage.type) return cell }In viewdidLoad(), i have added the estimated rowHeight and the automatic dimensions as well:messagetable.estimatedRowHeight = 185 messagetable.rowHeight = UITableView.automaticDimension
Posted
by Samarth.
Last updated
.
Post not yet marked as solved
0 Replies
561 Views
I am using speech Synthesizer to convert text to speech and then using the speech recognizer to take inputs from the user. Based on the user input, a new View controller is presented, where again speech synthesizer is used along with voice recognition. The process works perfectly on the simulator. However, when I run it on a physical device, after going to the second VC, the speech synthesizer volume is extremely low(It works perfectly on the first VC and I am also stopping the voice recognizer and deleting the node in the first VC). I tried manually setting the volume of the synthesizer to 1, but that doesnt make any difference.The strange thing is that it works perfectly fine if I plug in a head phone to my iPhone. This is really strange. Someone please help!
Posted
by Samarth.
Last updated
.
Post marked as solved
8 Replies
1.6k Views
hey guys! I am using a custom transition animation to transition between view controllers. Here is the codeextension UIViewController { func presentDetail(_ viewControllerToPresent: UIViewController) { let transition = CATransition() transition.duration = 0.3 transition.type = CATransitionType.push transition.subtype = CATransitionSubtype.fromRight transition.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) self.view.window?.layer.add(transition, forKey: kCATransition) present(viewControllerToPresent, animated: false, completion: nil) } func dismissDetail() { let transition = CATransition() transition.duration = 0.3 transition.type = CATransitionType.push transition.subtype = CATransitionSubtype.fromLeft self.view.window?.layer.add(transition, forKey: kCATransition) dismiss(animated: false, completion: nil) }}sometimes when I am transitioning to the new VC, the contents of the old VC shows up on the new VC for a split second and then refreshes. Can anyone please tell me why this is happening and how to fix this? This happens even on physical devices. The viewDidLoad() in the new VC does not do much either apart from calling a couple of functions.
Posted
by Samarth.
Last updated
.