Having issues recreating JTAppleCalender from patch the code
up vote
2
down vote
favorite
I'm having some issues trying to recreate a calendar from patchthecode's tutorial Here's the link: https://patchthecode.github.io/MainTutorial2/.
Here are a few of the error's i'm getting:
1.Cannot assign value of type 'ViewController' to type 'UICollectionViewDataSource?'
2.Cannot assign value of type 'ViewController' to type 'UICollectionViewDelegate?'
3.Value of type 'JTAppleCalendarView?' has no member 'registerCellViewXib'
4.Value of type 'JTAppleCalendarView?' has no member 'cellInset'
5.Use of undeclared type 'DateCell'
6.Invalid redeclaration of 'calendar(_:cellForItemAt:cellState:indexPath:)'
7.Use of unresolved identifier 'myCustomCell'
import UIKit
import JTAppleCalendar
class ViewController: UIViewController {
let white = UIColor.white
let darkPurple = UIColor.purple
let dimPurple = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)
@IBOutlet weak var calendarView: JTAppleCalendarView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
super.viewDidLoad()
calendarView.dataSource = self
calendarView.delegate = self
calendarView.registerCellViewXib(file: "CellView") // Registering your cell is manditory
calendarView.cellInset = CGPoint(x: 0, y: 0) // default is (3,3)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell: DateCell = JTAppleCell() as! DateCell
return cell
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
// let myCustomCell = cell as! CellView
// Setup Cell text
myCustomCell.dayLabel.text = cellState.text
// Setup text color
if cellState.dateBelongsTo == .thisMonth {
myCustomCell.dayLabel.textColor = UIColor.black
} else {
myCustomCell.dayLabel.textColor = UIColor.gray
}
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let myCustomCell = calendar.dequeueReusableCell(withReuseIdentifier: "CellView", for: indexPath) as! CellView
// self.calendar(self.calendar, willDisplay: myCustomCell, forItemAt: date, cellState: cellState, indexPath: indexPath)
return myCustomCell
}
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy MM dd"
let startDate = formatter.date(from: "2016 02 01")! // You can use date generated from a formatter
let endDate = Date() // You can also use dates created from this function
let parameters = ConfigurationParameters(startDate: startDate,
endDate: endDate,
numberOfRows: 6, // Only 1, 2, 3, & 6 are allowed
calendar: Calendar.current,
generateInDates: .forAllMonths,
generateOutDates: .tillEndOfGrid,
firstDayOfWeek: .sunday)
return parameters
}
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
let myCustomCell = cell as! CellView
// Let's make the view have rounded corners. Set corner radius to 25
myCustomCell.selectedView.layer.cornerRadius = 25
if cellState.isSelected {
myCustomCell.selectedView.isHidden = false
}
}
func calendar(_ calendar: JTAppleCalendarView, didDeselectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
let myCustomCell = cell as! CellView
myCustomCell.selectedView.isHidden = true
}
// Function to handle the text color of the calendar
func handleCellTextColor(view: JTAppleCell, cellState: CellState) {
guard let myCustomCell = view as? CellView else {
return
}
if cellState.isSelected {
myCustomCell.dayLabel.textColor = UIColor.purple
} else {
if cellState.dateBelongsTo == .thisMonth {
myCustomCell.dayLabel.textColor = UIColor.white
} else {
myCustomCell.dayLabel.textColor = UIColor.purple
}
}
}
// Function to handle the calendar selection
func handleCellSelection(view: JTAppleCell?, cellState: CellState) {
guard let myCustomCell = view as? CellView else {
return
}
if cellState.isSelected {
myCustomCell.selectedView.layer.cornerRadius = 25
myCustomCell.selectedView.isHidden = false
} else {
myCustomCell.selectedView.isHidden = true
}
}
extension UIColor {
convenience init(colorWithHexValue value: Int, alpha:CGFloat = 1.0){
self.init(
red: CGFloat((value & 0xFF0000) >> 16) / 255.0,
green: CGFloat((value & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(value & 0x0000FF) / 255.0,
alpha: alpha
)
}
}
ios swift calendar jtapplecalendar
add a comment |
up vote
2
down vote
favorite
I'm having some issues trying to recreate a calendar from patchthecode's tutorial Here's the link: https://patchthecode.github.io/MainTutorial2/.
Here are a few of the error's i'm getting:
1.Cannot assign value of type 'ViewController' to type 'UICollectionViewDataSource?'
2.Cannot assign value of type 'ViewController' to type 'UICollectionViewDelegate?'
3.Value of type 'JTAppleCalendarView?' has no member 'registerCellViewXib'
4.Value of type 'JTAppleCalendarView?' has no member 'cellInset'
5.Use of undeclared type 'DateCell'
6.Invalid redeclaration of 'calendar(_:cellForItemAt:cellState:indexPath:)'
7.Use of unresolved identifier 'myCustomCell'
import UIKit
import JTAppleCalendar
class ViewController: UIViewController {
let white = UIColor.white
let darkPurple = UIColor.purple
let dimPurple = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)
@IBOutlet weak var calendarView: JTAppleCalendarView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
super.viewDidLoad()
calendarView.dataSource = self
calendarView.delegate = self
calendarView.registerCellViewXib(file: "CellView") // Registering your cell is manditory
calendarView.cellInset = CGPoint(x: 0, y: 0) // default is (3,3)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell: DateCell = JTAppleCell() as! DateCell
return cell
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
// let myCustomCell = cell as! CellView
// Setup Cell text
myCustomCell.dayLabel.text = cellState.text
// Setup text color
if cellState.dateBelongsTo == .thisMonth {
myCustomCell.dayLabel.textColor = UIColor.black
} else {
myCustomCell.dayLabel.textColor = UIColor.gray
}
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let myCustomCell = calendar.dequeueReusableCell(withReuseIdentifier: "CellView", for: indexPath) as! CellView
// self.calendar(self.calendar, willDisplay: myCustomCell, forItemAt: date, cellState: cellState, indexPath: indexPath)
return myCustomCell
}
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy MM dd"
let startDate = formatter.date(from: "2016 02 01")! // You can use date generated from a formatter
let endDate = Date() // You can also use dates created from this function
let parameters = ConfigurationParameters(startDate: startDate,
endDate: endDate,
numberOfRows: 6, // Only 1, 2, 3, & 6 are allowed
calendar: Calendar.current,
generateInDates: .forAllMonths,
generateOutDates: .tillEndOfGrid,
firstDayOfWeek: .sunday)
return parameters
}
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
let myCustomCell = cell as! CellView
// Let's make the view have rounded corners. Set corner radius to 25
myCustomCell.selectedView.layer.cornerRadius = 25
if cellState.isSelected {
myCustomCell.selectedView.isHidden = false
}
}
func calendar(_ calendar: JTAppleCalendarView, didDeselectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
let myCustomCell = cell as! CellView
myCustomCell.selectedView.isHidden = true
}
// Function to handle the text color of the calendar
func handleCellTextColor(view: JTAppleCell, cellState: CellState) {
guard let myCustomCell = view as? CellView else {
return
}
if cellState.isSelected {
myCustomCell.dayLabel.textColor = UIColor.purple
} else {
if cellState.dateBelongsTo == .thisMonth {
myCustomCell.dayLabel.textColor = UIColor.white
} else {
myCustomCell.dayLabel.textColor = UIColor.purple
}
}
}
// Function to handle the calendar selection
func handleCellSelection(view: JTAppleCell?, cellState: CellState) {
guard let myCustomCell = view as? CellView else {
return
}
if cellState.isSelected {
myCustomCell.selectedView.layer.cornerRadius = 25
myCustomCell.selectedView.isHidden = false
} else {
myCustomCell.selectedView.isHidden = true
}
}
extension UIColor {
convenience init(colorWithHexValue value: Int, alpha:CGFloat = 1.0){
self.init(
red: CGFloat((value & 0xFF0000) >> 16) / 255.0,
green: CGFloat((value & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(value & 0x0000FF) / 255.0,
alpha: alpha
)
}
}
ios swift calendar jtapplecalendar
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm having some issues trying to recreate a calendar from patchthecode's tutorial Here's the link: https://patchthecode.github.io/MainTutorial2/.
Here are a few of the error's i'm getting:
1.Cannot assign value of type 'ViewController' to type 'UICollectionViewDataSource?'
2.Cannot assign value of type 'ViewController' to type 'UICollectionViewDelegate?'
3.Value of type 'JTAppleCalendarView?' has no member 'registerCellViewXib'
4.Value of type 'JTAppleCalendarView?' has no member 'cellInset'
5.Use of undeclared type 'DateCell'
6.Invalid redeclaration of 'calendar(_:cellForItemAt:cellState:indexPath:)'
7.Use of unresolved identifier 'myCustomCell'
import UIKit
import JTAppleCalendar
class ViewController: UIViewController {
let white = UIColor.white
let darkPurple = UIColor.purple
let dimPurple = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)
@IBOutlet weak var calendarView: JTAppleCalendarView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
super.viewDidLoad()
calendarView.dataSource = self
calendarView.delegate = self
calendarView.registerCellViewXib(file: "CellView") // Registering your cell is manditory
calendarView.cellInset = CGPoint(x: 0, y: 0) // default is (3,3)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell: DateCell = JTAppleCell() as! DateCell
return cell
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
// let myCustomCell = cell as! CellView
// Setup Cell text
myCustomCell.dayLabel.text = cellState.text
// Setup text color
if cellState.dateBelongsTo == .thisMonth {
myCustomCell.dayLabel.textColor = UIColor.black
} else {
myCustomCell.dayLabel.textColor = UIColor.gray
}
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let myCustomCell = calendar.dequeueReusableCell(withReuseIdentifier: "CellView", for: indexPath) as! CellView
// self.calendar(self.calendar, willDisplay: myCustomCell, forItemAt: date, cellState: cellState, indexPath: indexPath)
return myCustomCell
}
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy MM dd"
let startDate = formatter.date(from: "2016 02 01")! // You can use date generated from a formatter
let endDate = Date() // You can also use dates created from this function
let parameters = ConfigurationParameters(startDate: startDate,
endDate: endDate,
numberOfRows: 6, // Only 1, 2, 3, & 6 are allowed
calendar: Calendar.current,
generateInDates: .forAllMonths,
generateOutDates: .tillEndOfGrid,
firstDayOfWeek: .sunday)
return parameters
}
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
let myCustomCell = cell as! CellView
// Let's make the view have rounded corners. Set corner radius to 25
myCustomCell.selectedView.layer.cornerRadius = 25
if cellState.isSelected {
myCustomCell.selectedView.isHidden = false
}
}
func calendar(_ calendar: JTAppleCalendarView, didDeselectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
let myCustomCell = cell as! CellView
myCustomCell.selectedView.isHidden = true
}
// Function to handle the text color of the calendar
func handleCellTextColor(view: JTAppleCell, cellState: CellState) {
guard let myCustomCell = view as? CellView else {
return
}
if cellState.isSelected {
myCustomCell.dayLabel.textColor = UIColor.purple
} else {
if cellState.dateBelongsTo == .thisMonth {
myCustomCell.dayLabel.textColor = UIColor.white
} else {
myCustomCell.dayLabel.textColor = UIColor.purple
}
}
}
// Function to handle the calendar selection
func handleCellSelection(view: JTAppleCell?, cellState: CellState) {
guard let myCustomCell = view as? CellView else {
return
}
if cellState.isSelected {
myCustomCell.selectedView.layer.cornerRadius = 25
myCustomCell.selectedView.isHidden = false
} else {
myCustomCell.selectedView.isHidden = true
}
}
extension UIColor {
convenience init(colorWithHexValue value: Int, alpha:CGFloat = 1.0){
self.init(
red: CGFloat((value & 0xFF0000) >> 16) / 255.0,
green: CGFloat((value & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(value & 0x0000FF) / 255.0,
alpha: alpha
)
}
}
ios swift calendar jtapplecalendar
I'm having some issues trying to recreate a calendar from patchthecode's tutorial Here's the link: https://patchthecode.github.io/MainTutorial2/.
Here are a few of the error's i'm getting:
1.Cannot assign value of type 'ViewController' to type 'UICollectionViewDataSource?'
2.Cannot assign value of type 'ViewController' to type 'UICollectionViewDelegate?'
3.Value of type 'JTAppleCalendarView?' has no member 'registerCellViewXib'
4.Value of type 'JTAppleCalendarView?' has no member 'cellInset'
5.Use of undeclared type 'DateCell'
6.Invalid redeclaration of 'calendar(_:cellForItemAt:cellState:indexPath:)'
7.Use of unresolved identifier 'myCustomCell'
import UIKit
import JTAppleCalendar
class ViewController: UIViewController {
let white = UIColor.white
let darkPurple = UIColor.purple
let dimPurple = #colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)
@IBOutlet weak var calendarView: JTAppleCalendarView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
super.viewDidLoad()
calendarView.dataSource = self
calendarView.delegate = self
calendarView.registerCellViewXib(file: "CellView") // Registering your cell is manditory
calendarView.cellInset = CGPoint(x: 0, y: 0) // default is (3,3)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let cell: DateCell = JTAppleCell() as! DateCell
return cell
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
// let myCustomCell = cell as! CellView
// Setup Cell text
myCustomCell.dayLabel.text = cellState.text
// Setup text color
if cellState.dateBelongsTo == .thisMonth {
myCustomCell.dayLabel.textColor = UIColor.black
} else {
myCustomCell.dayLabel.textColor = UIColor.gray
}
}
func calendar(_ calendar: JTAppleCalendarView, cellForItemAt date: Date, cellState: CellState, indexPath: IndexPath) -> JTAppleCell {
let myCustomCell = calendar.dequeueReusableCell(withReuseIdentifier: "CellView", for: indexPath) as! CellView
// self.calendar(self.calendar, willDisplay: myCustomCell, forItemAt: date, cellState: cellState, indexPath: indexPath)
return myCustomCell
}
func configureCalendar(_ calendar: JTAppleCalendarView) -> ConfigurationParameters {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy MM dd"
let startDate = formatter.date(from: "2016 02 01")! // You can use date generated from a formatter
let endDate = Date() // You can also use dates created from this function
let parameters = ConfigurationParameters(startDate: startDate,
endDate: endDate,
numberOfRows: 6, // Only 1, 2, 3, & 6 are allowed
calendar: Calendar.current,
generateInDates: .forAllMonths,
generateOutDates: .tillEndOfGrid,
firstDayOfWeek: .sunday)
return parameters
}
func calendar(_ calendar: JTAppleCalendarView, didSelectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
let myCustomCell = cell as! CellView
// Let's make the view have rounded corners. Set corner radius to 25
myCustomCell.selectedView.layer.cornerRadius = 25
if cellState.isSelected {
myCustomCell.selectedView.isHidden = false
}
}
func calendar(_ calendar: JTAppleCalendarView, didDeselectDate date: Date, cell: JTAppleCell?, cellState: CellState) {
let myCustomCell = cell as! CellView
myCustomCell.selectedView.isHidden = true
}
// Function to handle the text color of the calendar
func handleCellTextColor(view: JTAppleCell, cellState: CellState) {
guard let myCustomCell = view as? CellView else {
return
}
if cellState.isSelected {
myCustomCell.dayLabel.textColor = UIColor.purple
} else {
if cellState.dateBelongsTo == .thisMonth {
myCustomCell.dayLabel.textColor = UIColor.white
} else {
myCustomCell.dayLabel.textColor = UIColor.purple
}
}
}
// Function to handle the calendar selection
func handleCellSelection(view: JTAppleCell?, cellState: CellState) {
guard let myCustomCell = view as? CellView else {
return
}
if cellState.isSelected {
myCustomCell.selectedView.layer.cornerRadius = 25
myCustomCell.selectedView.isHidden = false
} else {
myCustomCell.selectedView.isHidden = true
}
}
extension UIColor {
convenience init(colorWithHexValue value: Int, alpha:CGFloat = 1.0){
self.init(
red: CGFloat((value & 0xFF0000) >> 16) / 255.0,
green: CGFloat((value & 0x00FF00) >> 8) / 255.0,
blue: CGFloat(value & 0x0000FF) / 255.0,
alpha: alpha
)
}
}
ios swift calendar jtapplecalendar
ios swift calendar jtapplecalendar
asked Nov 9 at 23:03
Bubble Turtle
111
111
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53234372%2fhaving-issues-recreating-jtapplecalender-from-patch-the-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown