Post not yet marked as solved
Im testing against this: case 0,6,7,13,14,20,21,27,28,34,35,41:
The case == the position of cells in collectionview.
I am trying to get the string interpolation to equal the cells position.
case 0,6,7,13,14,20,21,27,28,34,35,41:
if Int(cell.dayOfMonth.text = "\(indexPath.item)" > 0 { // <=== I get the error on this line
cell.dayOfMonth.textColor = UIColor.lightGray
}
Post not yet marked as solved
Im testing the (position of cells in a collectionview): case 0,6,7,13,14,20,21,27,28,34,35,41:
But I can't seem to get the string interpolation to equal the cell position.
case 0,6,7,13,14,20,21,27,28,34,35,41:
if Int(cell.dayOfMonth.text = "\(indexPath.item)" > 0 { // <=== I get the error on this line.
cell.dayOfMonth.textColor = UIColor.lightGray
}
Thanks, this helped a lot!
Correct... My apologies, I didn't specify. I meant as far as using a reusable Identifer...I was unable to add a cell to the collectionview nor was I able to see the identifier name in the property inspector. So I was wondering if it can be done programmatically.
Sure, the set up is for a calendar. When the user taps a cell from the collectionview.. model view appears with date(cell) details. From there the user can also scroll the individual dates and their details.
Okay got it, is it something like this? what do that block of code look like?
cell.detailTextLabel!.isHidden = theSelectedRow != nil && theSelectedRow! == indexPath.item
By forward and backward, I mean by scrolling the views (of UILabels), the labels are populated with said arrays.
Thanks @ Claude31
That was just too easy to miss. I don't know how I did that.
Post not yet marked as solved
Thank you OOPerIm getting the errors:Use of unresolved identifier 'present'present(modalCalVC, animated: true, completion: nil)andCannot use optional chaining on non-optional value of type 'Any'guardlet modalCalVC = self.storyboard?.instantiateViewController(identifier:I believe its because my collectionView class is a UIView and not a UIViewController.How can I get around this problem?
Post not yet marked as solved
So I think I know why I am having the problem but Im not sure.I am trying to pass true/false value from a UIView to a UIViewController is there a way to work around this?Is it my code or something else that is making the two not communicate?Below I created a gesture button that will "unhide" a view that is in another VC.mySwiftFile1.swiftimport UIKit
import SwiftUI
class SeasonsView: UIView, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, SeasonViewDelegate {
@objc func handleLongPress(gesture: UILongPressGestureRecognizer) {
if gesture.state == UIGestureRecognizer.State.began {
ModalCalViewController.view.isHidden = false
print("Long press is working")
}
}This is my child viewcontroller with a button to make it hidden again.mySwiftFile2.swiftimport UIKit
class ModalCalViewController: UIViewController {
@IBAction func hideChildControllerBtn(_ sender: Any) {
// Button to set view back to hidden
view.isHidden = true
}
override func viewDidLoad() {
super.viewDidLoad()
// Default view is set to hidden.
view.isHidden = true
view.backgroundColor = UIColor.red
view.isOpaque = false
}
}How can I have mySwiftFile1 set the child controller in mySwiftFile2 to "unhidden"?
Yes. "App Store Connect" lets you distribute privately.
Post not yet marked as solved
I believe you need to put a button or some type of segue on your "hello world" view to get to the other pages / views your talking about.
Post not yet marked as solved
the artical is interesting but not what im looking..But your opinion is exactly what Im looking to create. Thanks a million! "IB" Im assuming an IB outlet?Im going to be all over it now like butter on toast. Thanks for the help!
Post not yet marked as solved
Im not sure if that helps... I have zero programming experience / self taught.I am trying to programmatically create a modal view appear half screen when a cell is longpressed.so far I have:privatefunc collectionView(_ collectionView: UITapGestureRecognizer, didSelectItemAt indexPath: IndexPath) {
func longPressed(sender: UILongPressGestureRecognizer)
{
let longPressed = UITapGestureRecognizer(target: self, action: "longPressed:")
}
}along with the intial code:// Reuseable Cell
setupViews()
myCollectionView.delegate=self
myCollectionView.dataSource=self
myCollectionView.register(dateCVCell.self, forCellWithReuseIdentifier: "Cell")
}
// cell selected BG color change
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let cell=collectionView.cellForItem(at: indexPath)
cell?.backgroundColor=Colors.blue
let lbl = cell?.subviews[1] as! UILabel
lbl.textColor=UIColor.white
}and it seems as if Im missing something but I dont know what.
Claude31 WOW! I would have never have figured that one out. Its just a loop I need to run in the background for a playlist.thanks a million!
This is from a old Swift 3 file that worked flawlessly but since updating it to Swift 4, 5 and doing the recommended fixes. It went haywire.This is what I have defining the firstDayOfTheMonth:Its also giving me these two errors:'Declaration is only valid at file scope' 'Type 'String' has no member 'dateFormatter'//get first day of the monthextension Date { var weekday: Int { return Calendar.current.component(.weekday, from: self) } var firstDayOfTheMonth: Date { return Calendar.current.date(from: Calendar.current.dateComponents([.year,.month], from: self))! }}//get date from stringextension String { static var dateFormatter: DateFormatter = { let formatter = DateFormatter() formatter.dateFormat = "yyyy-MM-dd" return formatter }() var date: Date? { return String.dateFormatter.date(from: self) } }