Swift 3 OSX app textfield and pop button to the clipboard - swift

I'm new with Swift, but what I would like to do basically is
now what the user selected for Q1 : Q 4,
if for example the user selected Yes at Q1, no to Q2 then I would like to add a string to the clipboard :
Q1 : Question one is there : Yes
Q2 : Question two is here : No
and last thing from the button "done"
I would like to added to the previous clipboard and copy what ever the text is on the first textfield and put all together into the clipboard
// Case Questions
#IBOutlet weak var qUestionOne: NSPopUpButton!
#IBOutlet weak var qUestionTwo: NSPopUpButton!
#IBOutlet weak var qUestionTree: NSPopUpButton!
#IBOutlet weak var qUestionFor: NSPopUpButton!
// CaseNote
#IBOutlet weak var cAseNoteTextField: NSTextField!
// Draft
#IBOutlet weak var dRaftNote: NSTextField!
// buttons
#IBAction func dOneButton(_ sender: Any) {
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}

Related

The picture goes up because the description is long how can I fix this?

When the picture description is long, my picture disappears, I can't see it. How can I show full size of text and full size of images?
How can I scroll the text up and down?
FavoriteDetailViewController
import UIKit
import ProgressHUD
class FavoriteDetailViewController: UIViewController {
#IBOutlet weak var shortdescriptionLabel: UILabel!
#IBOutlet weak var favoriteImageView: UIImageView!
#IBOutlet weak var favoriteTitleLabel: UILabel!
#IBOutlet weak var descriptionLabel: UILabel!
#IBOutlet weak var nameField: UITextField!
var breed: Breed!
override func viewDidLoad() {
super.viewDidLoad()
populateView()
}
private func populateView() {
favoriteImageView.kf.setImage(with: breed.image?.asUrl)
favoriteTitleLabel.text = breed.name
descriptionLabel.text = breed.description
shortdescriptionLabel.text = breed.shortDescription
}
#IBAction func favoriteButton(_ sender: UIButton) {
guard let name = nameField.text?.trimmingCharacters(in: .whitespaces),
!name.isEmpty else {
ProgressHUD.showError("Please enter your name")
return
}
print("Hello \(name)")
}
}
I made the text smaller but it's very illegible
I dropped the spacing, it looks bad too
I want to make the whole text look nice and not spoil the picture. What is the solution? Is it possible to move the label up and down?

Xcode - push data into the firebase storage

I thought to design the program like this.
The user type the data in each text fields; Name, Passwords and Comments.
By press the button, store the input data into the Firebase storage.
However, the error occurred.
I wonder which parts need to fix or add.
Code
Error
private let database = Database.database().reference()
#IBOutlet weak var NameInput: UITextField!
#IBOutlet weak var Passwords: UITextField!
#IBOutlet weak var Rate: UISegmentedControl!
#IBOutlet weak var Comment: UITextField!
#IBOutlet weak var UploadButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
#IBAction func UbuttonPressed(_ sender: Any) {
let review_data: [String: Any?] = [
"Name": NameInput.text,
"Passwords": Passwords.text,
// "Rate": Rate.text,
"Comment": Comment.text
]
database.child("Review_\(Int.random(in: 0..<1000))").setValue(review_data)
}
You probably have a storyboard reference to one of the #IBOutlets which you renamed/deleted in your source code, but haven't removed/changed it in the storyboard. See this article for more info.

How to resize the detailsView after cross button is clicked after the closing view is hidden?

[![when the cross button is clicked, the closingView is hidden.][1]][1]
import UIKit
import IBAnimatable
class ViewController: UIViewController {
#IBOutlet weak var closingView: AnimatableView!
#IBOutlet weak var detailsView: AnimatableView!
#IBOutlet weak var btnClose: UIButton!
#IBOutlet weak var closeViewBtn: UIView!
#IBOutlet weak var scrollView: UIScrollView!
var isCloseButtonTapped = false
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
#IBAction func btnCloseAction(_ sender: Any) {
isCloseButtonTapped = !isCloseButtonTapped
if isCloseButtonTapped{
closingView.isHidden = true
}else{
//
}
}
}
[1]: https://i.stack.imgur.com/CpH2A.png
You can add closingView and detailsView inside a UIStackView. When the closingView is hidden the detailsView will fill up the entire space in the parent UIStackView.

How can I carry out multiple different animations at different times with the same UIButton?

I am creating an animation sequence where when one button is pressed one object fades out. When the same button is pressed again another object fades out. This keeps happening until 8 objects are faded out. I have tried and played around with code and so far have got the code to fade out one object, and two or more at a time, but have not successfully been able to do it as described above. This is my code so far:
import UIKit
class DrinkWaterViewController: UIViewController {
#IBOutlet weak var glassOne: UIImageView!
#IBOutlet weak var glassTwo: UIImageView!
#IBOutlet weak var glassThree: UIImageView!
#IBOutlet weak var glassFour: UIImageView!
#IBOutlet weak var glassFive: UIImageView!
#IBOutlet weak var glassSix: UIImageView!
#IBOutlet weak var glassSeven: UIImageView!
#IBOutlet weak var glassEight: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
self.glassOne.alpha = 1.0
self.glassTwo.alpha = 1.0
}
#IBAction func drunkOne(_ sender: Any){
if self.glassOne.alpha == 1.0{
UIView.animate(withDuration: 1.5, delay: 0.2, animations:
{self.glassOne.alpha = CGFloat(0.1)}
)
}
}
Put your glasses into an array glasses and add a property to keep track of nextToFade. Then just fade the glasses[nextToFade] and increment nextToFade by 1:
class DrinkWaterViewController: UIViewController {
#IBOutlet weak var glassOne: UIImageView!
#IBOutlet weak var glassTwo: UIImageView!
#IBOutlet weak var glassThree: UIImageView!
#IBOutlet weak var glassFour: UIImageView!
#IBOutlet weak var glassFive: UIImageView!
#IBOutlet weak var glassSix: UIImageView!
#IBOutlet weak var glassSeven: UIImageView!
#IBOutlet weak var glassEight: UIImageView!
// array to hold the glasses so that they can be indexed
var glasses = [UIImageView]()
// index of next glass to fade
var nextToFade = 0
override func viewDidLoad() {
super.viewDidLoad()
// put the glasses into the array
glasses = [glassOne, glassTwo, glassThree, glassFour,
glassFive, glassSix, glassSeven, glassEight]
// make sure they're all visible
glasses.forEach { $0.alpha = 1.0 }
}
#IBAction func drunkOne(_ sender: Any) {
// make sure not to index beyond the end of the array
guard nextToFade < glasses.count else { return }
let glass = glasses[nextToFade]
nextToFade += 1
UIView.animate(withDuration: 1.5, delay: 0.2, animations:
{ glass.alpha = 0.1 }
)
}
}

Can't make sens of UIStepper (S)

I'm trying to make an app to count different tokens in a board game. I thought it would be easy peasy, but not quite.
I succeeded in adding one UIStepper to count one kind of token, but I don't know how to add the other four. This is what I've got so far:
import UIKit
class ViewController: UIViewController {
#IBOutlet weak var theLabel: UILabel!
#IBOutlet weak var stepper: UIStepper!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
#IBAction func StepperTapped(sender: UIStepper) {
self.theLabel.text = "\(self.stepper.value)"
}
}
I got one action and two outlets.
import UIKit
class ViewController: UIViewController {
#IBOutlet weak var theLabel: UILabel!
#IBOutlet weak var stepper: UIStepper!
#IBOutlet weak var theLabel2: UILabel!
#IBOutlet weak var stepper2: UIStepper!
#IBOutlet weak var theLabel3: UILabel!
#IBOutlet weak var stepper3: UIStepper!
#IBOutlet weak var theLabel4: UILabel!
#IBOutlet weak var stepper4: UIStepper!
#IBOutlet weak var theLabel5: UILabel!
#IBOutlet weak var stepper5: UIStepper!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
#IBAction func StepperTapped(sender: UIStepper) {
self.theLabel.text = "\(self.stepper.value)"
}
#IBAction func StepperTapped2(sender: UIStepper) {
self.theLabel2.text = "\(self.stepper2.value)"
}
#IBAction func StepperTapped3(sender: UIStepper) {
self.theLabel3.text = "\(self.stepper3.value)"
}
#IBAction func StepperTapped4(sender: UIStepper) {
self.theLabel4.text = "\(self.stepper4.value)"
}
#IBAction func StepperTapped5(sender: UIStepper) {
self.theLabel5.text = "\(self.stepper5.value)"
}
}