2016-08-18 58 views
0

我正在嘗試使用CVCalendar pod,但無法讓它加載任何東西。在Xcode中沒有錯誤消息,但我必須做錯了什麼。花了整整一天的時間試圖弄清楚這一點。CVCalendar空白但沒有錯誤

https://github.com/Mozharovsky/CVCalendar/

1)我安裝了可可豆莢的事情,和進口CVCalendar

2)正下方導入我創建2個協議 - CVCalendarViewDelegate和CVCalendarMenuViewDelegate (我有感覺,這可能是問題 - 還沒有與前代表和IM的工作還是蠻新的Xcode)

2)我創建了兩個視圖,並在檢查我改變類名CVCalendarMenuView和CVCalendarView

2)然後爲他們創建網點。

3)然後我加入這個

override func viewDidLayoutSubviews() { 
    super.viewDidLayoutSubviews() 

    menuView.commitMenuViewUpdate() 
    calendarView.commitCalendarViewUpdate() 
} 

在一個測試項目,整個事情是這樣的:

import UIKit 
import CVCalendar 

protocol CVCalendarViewDelegate{} 
protocol CVCalendarMenuViewDelegate{} 

class Test: UIViewController { 

    @IBOutlet var menuView: CVCalendarMenuView! 
    @IBOutlet var calendarView: CVCalendarView! 

    override func viewDidLayoutSubviews() { 
     super.viewDidLayoutSubviews() 

     menuView.commitMenuViewUpdate() 
     calendarView.commitCalendarViewUpdate() 
    } 

    override func viewDidLoad() { 
     super.viewDidLoad() 

    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 
} 

菜單視圖顯示爲空白字段。日曆視圖完全不顯示。沒有日期沒有按鈕。

+0

你有工作嗎? –

回答

0

首先從https://github.com/Mozharovsky/CVCalendar/下載完整項目(推送克隆或下載按鈕)。在那裏你可以找到完整的CVCalendar開發者演示。我們將看到這樣:

enter image description here

我定你的代碼:

ViewController.swift

import UIKit 
import CVCalendar 

class ViewController: UIViewController, CVCalendarViewDelegate, CVCalendarMenuViewDelegate { 

@IBOutlet var menuView: CVCalendarMenuView! 
@IBOutlet var calendarView: CVCalendarView! 

override func viewDidAppear(animated: Bool) { 

    super.viewDidLoad() 

    // Appearance delegate [Unnecessary] 
    calendarView.calendarAppearanceDelegate = self 

    // Animator delegate [Unnecessary] 
    calendarView.animatorDelegate = self 

    // Menu delegate [Required] 
    menuView.menuViewDelegate = self 

    // Calendar delegate [Required] 
    calendarView.calendarDelegate = self 
} 

override func viewDidLayoutSubviews() { 
    super.viewDidLayoutSubviews() 

    menuView.commitMenuViewUpdate() 
    calendarView.commitCalendarViewUpdate() 
} 

override func viewDidLoad() { 
    super.viewDidLoad() 

} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Dispose of any resources that can be recreated. 
} 

/// Required method to implement! 
func presentationMode() -> CalendarMode { 
    return .MonthView 
} 

/// Required method to implement! 
func firstWeekday() -> Weekday { 
    return .Sunday 
} 
} 

Main.storyboard

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> 
<dependencies> 
    <deployment identifier="iOS"/> 
    <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> 
    <capability name="Constraints to layout margins" minToolsVersion="6.0"/> 
</dependencies> 
<scenes> 
    <!--View Controller--> 
    <scene sceneID="tne-QT-ifu"> 
     <objects> 
      <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="stackoverflow_39028382" customModuleProvider="target" sceneMemberID="viewController"> 
       <layoutGuides> 
        <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> 
        <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> 
       </layoutGuides> 
       <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> 
        <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> 
        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 
        <subviews> 
         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="KhD-VO-LEi" customClass="CVCalendarMenuView" customModule="CVCalendar"> 
          <rect key="frame" x="0.0" y="28" width="600" height="57"/> 
          <color key="backgroundColor" name="controlHighlightColor" catalog="System" colorSpace="catalog"/> 
          <constraints> 
           <constraint firstAttribute="height" constant="57" id="d0p-pY-lAt"/> 
          </constraints> 
         </view> 
         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8CS-QV-kqC" customClass="CVCalendarView" customModule="CVCalendar"> 
          <rect key="frame" x="0.0" y="84" width="600" height="415"/> 
          <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/> 
          <constraints> 
           <constraint firstAttribute="height" constant="415" id="Lmo-yR-ea1"/> 
          </constraints> 
         </view> 
        </subviews> 
        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> 
        <constraints> 
         <constraint firstItem="KhD-VO-LEi" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="8" id="7y9-B3-7Pg"/> 
         <constraint firstItem="8CS-QV-kqC" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" constant="-20" id="Bce-Pi-kYh"/> 
         <constraint firstItem="8CS-QV-kqC" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="64" id="WsH-l1-nX9"/> 
         <constraint firstItem="KhD-VO-LEi" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" constant="-20" id="ut9-R1-Exb"/> 
         <constraint firstAttribute="trailingMargin" secondItem="KhD-VO-LEi" secondAttribute="trailing" constant="-20" id="wAU-K8-TMN"/> 
         <constraint firstAttribute="trailingMargin" secondItem="8CS-QV-kqC" secondAttribute="trailing" constant="-20" id="wpf-0X-gor"/> 
        </constraints> 
       </view> 
       <connections> 
        <outlet property="calendarView" destination="8CS-QV-kqC" id="GND-0P-wUz"/> 
        <outlet property="menuView" destination="KhD-VO-LEi" id="inF-0o-ViY"/> 
       </connections> 
      </viewController> 
      <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> 
     </objects> 
    </scene> 
</scenes> 
</document> 

結果這段代碼:

enter image description here

+0

那麼,你測試過這個代碼嗎?它有幫助嗎? –

0

,我認爲你的錯誤是在這裏:

protocol CVCalendarViewDelegate{} 
protocol CVCalendarMenuViewDelegate{} 

class Test: UIViewController { 

該文檔是不是所有的清楚,但如果被提示「添加這些協議'您需要將它們添加到類即:

class Test: UIViewController,CVCalendarViewDelegate,CVCalendarMenuViewDelegate {