1

I'm having trouble getting a view to actually display. I declare a variable of type CKCalenderView (which is linked from the storyboard). I then try to display it once the application loads. However, I'm still getting stuck on the splash screen. I'm new to Swift and iOS so I'm probably missing something obvious, but any help would be appreciated!

   import UIKit

class ViewController: UIViewController, CKCalendarViewDelegate {

@IBOutlet weak var mainCalendar: CKCalendarView!


override func viewDidLoad() {
    super.viewDidLoad()
    mainCalendar.delegate = self;
    mainCalendar.hidden = false;
    mainCalendar.bringSubviewToFront(mainCalendar);
    //self.view.addSubview(mainCalendar);

    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
}
Dan
  • 475
  • 2
  • 5
  • 11
  • Did you define the initial view controller? – milo526 Aug 04 '15 at 20:46
  • Yes, I believe it is defined as the initial view controller. That is indicated by the arrow on the storyboard, correct? – Dan Aug 04 '15 at 20:51
  • Press Cmd+7 in Xcode, this brings you to the "Breakpoint" lane. Have you defined any breakpoints here? – Darko Aug 04 '15 at 21:03
  • If it's linked to the storyboard, then you shouldn't have to do anything to get it to display. Are your constraints set up? – Caleb Aug 04 '15 at 21:03
  • I don't have any breakpoints it appears. – Dan Aug 04 '15 at 21:07
  • @Caleb I added constraints, but its still getting stuck on the splash screen. – Dan Aug 04 '15 at 21:08
  • Could it be because I did not import my Calendar Kit correctly to the view controller? It's native to Objective C, so I had to create a bridging header. The code inside is:
    #import "CalendarKit.h" #import "CKCalendarView.h" #import "CKCalendarViewController.h" #import "NSCalendarCategories.h" #import "NSDate+Components.h"
    – Dan Aug 04 '15 at 21:12
  • I wonder how you have integrated a 3rd party component like CKCalendarView in your application as an iOS beginner... Which kind or project have you created? A single view application? – Darko Aug 04 '15 at 21:13
  • @Darko Yes, I created a single view project. I use cocoapods to install 3rd party components. – Dan Aug 04 '15 at 21:15
  • Have you added the bridging header correctly to the Xcode project settings? See here: http://stackoverflow.com/a/31784281/2664531 – Darko Aug 04 '15 at 21:18
  • How did you add the CKCalendarView with Interface Builder to the view controller? It's an @IBOutlet. – Darko Aug 04 '15 at 21:21
  • @Darko I created a view object and added inside the view controller. I then changed the object's class to CKCalenderView and dragged it from the interface. I believe my bridge heading is correct; to add it I created a objective c file in my project and then was prompted whether I wanted to add a bridge. Is there another step I have to take? – Dan Aug 04 '15 at 21:27
  • Can you pass the Splashscreen when you remove the CKCalenderView in Interface Builder? Just to test if the CKCalenderView is the problem. You then also have to comment out the CKCalenderView related code. – Darko Aug 04 '15 at 21:39
  • @Darko Yes, once the CKCalenderView code is removed, it passes the splash screen. – Dan Aug 04 '15 at 21:42
  • Ok, then please try to create the CKCalenderView in code and not in IB. Just remove the '@IBOutlet weak' and call mainCalendar = CKCalendarView() in viewDidLoad. You also have to set the frame of mainCalendar afterwards and add it as a sub view with self.view.addSubview(mainCalendar). I assume that IB has a problem to create the CKCalendarView. – Darko Aug 04 '15 at 21:54
  • @Darko Wow, that seems to have done it! Appreciate the help! Last thing, how do I add constraints if I can't work in the interface builder? – Dan Aug 04 '15 at 22:13
  • Great. Programatic constraints are really hard in iOS. Try "SnapKit", it makes it much easier. – Darko Aug 04 '15 at 22:16
  • why did you uncomment view.addsubview()? – DanielEdrisian Aug 04 '15 at 23:24

0 Answers0