2016-09-10 3 views
0

私は単純な作業であると思ったことに固執しています。 UITableViewはPrototype Cellに設定されています。プロトタイプセルに接続しているときにセルエラーをデキューできません

「ケース」に特定の用途のためにいくつかのセルを追加しました。

"識別子TankStartCellのセルをデキューできません - 識別子のためにペンまたはクラスを登録するか、ストーリーボードにプロトタイプセルを接続する必要があります"というエラーが表示されますが、シーンはプロトタイプセルとして設定されます。

問題のセルに識別子に "StartTankCell"があります。

ロケーションセルが機能します。

私が追加しようとしている: self.tableView.registerClass(UITableViewCell.self、forCellReuseIdentifier: "StartTankCell") が、ノー行きます。 クラスをUIViewControllerにして、UITableViewDelegateを追加しようとしましたが、行っていません。

private let NumberOfSections: Int    = 6 
private let NumberOfRowsInSection0: Int   = 1 
private let NumberOfRowsInSection1: Int   = 4 
private let NumberOfRowsInSection2: Int   = 5 
private let NumberOfRowsInSection3: Int   = 6 
private let NumberOfRowsInSection4: Int   = 8 
private let NumberOfRowsInSection5: Int   = 1 



// Section 0 Cells 
private let DiveLocationIndex: NSIndexPath    = NSIndexPath(forRow: 0, inSection: 0) 

// Section 1 Cells 
private let DiveStartingPressureIndex: NSIndexPath  = NSIndexPath(forRow: 0, inSection: 1) 
private let DiveEndingPressureIndex: NSIndexPath  = NSIndexPath(forRow: 1, inSection: 1) 
private let DiveTempPickerIndexAir: NSIndexPath   = NSIndexPath(forRow: 2, inSection: 1) 
private let DiveTempPickerIndexWater: NSIndexPath  = NSIndexPath(forRow: 3, inSection: 1) 

// Section 2 Cells 
private let DiveWaterIndex: NSIndexPath     = NSIndexPath(forRow: 0, inSection: 2) 
private let DiveWeatherIndex: NSIndexPath    = NSIndexPath(forRow: 1, inSection: 2) 
private let DiveSurfaceIndex: NSIndexPath    = NSIndexPath(forRow: 2, inSection: 2) 
private let DiveCurrentsIndex: NSIndexPath    = NSIndexPath(forRow: 3, inSection: 2) 
private let DiveVisibilityIndex: NSIndexPath   = NSIndexPath(forRow: 4, inSection: 2) 

// Section 3 Cells 
private let DiveEntryTypeIndex: NSIndexPath    = NSIndexPath(forRow: 0, inSection: 3) 
private let DiveWeightIndex: NSIndexPath    = NSIndexPath(forRow: 1, inSection: 3) 
private let DiveDiveSuitIndex: NSIndexPath    = NSIndexPath(forRow: 2, inSection: 3) 
private let DiveCircuitIndex: NSIndexPath    = NSIndexPath(forRow: 3, inSection: 3) 
private let DiveAirTypeIndex: NSIndexPath    = NSIndexPath(forRow: 4, inSection: 3) 
private let DiveDiveTypeIndex: NSIndexPath    = NSIndexPath(forRow: 5, inSection: 3) 


// Section 4 Cells 
private let DiveMasterTitleIndex: NSIndexPath   = NSIndexPath(forRow: 0, inSection: 4) 
private let DiveMasterIndex: NSIndexPath    = NSIndexPath(forRow: 1, inSection: 4) 
private let DiveCenterTitleIndex: NSIndexPath   = NSIndexPath(forRow: 2, inSection: 4) 
private let DiveCenterIndex: NSIndexPath    = NSIndexPath(forRow: 3, inSection: 4) 
private let DiveBoatTitleIndex: NSIndexPath    = NSIndexPath(forRow: 4, inSection: 4) 
private let DiveBoatIndex: NSIndexPath     = NSIndexPath(forRow: 5, inSection: 4) 
private let DiveTripTitleIndex: NSIndexPath    = NSIndexPath(forRow: 6, inSection: 4) 
private let DiveTripIndex: NSIndexPath     = NSIndexPath(forRow: 7, inSection: 4) 



override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ 

    var cell: UITableViewCell! 

    switch indexPath 
    { 

    // Section 0 
    case DiveLocationIndex: 
     cell = tableView.dequeueReusableCellWithIdentifier(Resource.LocationCell) 
     cell.textLabel!.text = "Location".localized 
     cell.detailTextLabel!.text = String(format: "%f, %f", self.latitude, self.longitude) 




    // Section 1 
    case DiveStartingPressureIndex: 
     let cell : DiveStartTankPressureTableViewCell = tableView.dequeueReusableCellWithIdentifier("TankStartCell", forIndexPath: indexPath) as! DiveStartTankPressureTableViewCell 

     cell.lbl_Start_Pressure.text = Strings.StartingPressure.localized 
     cell.txtStartPressure_Symbol.placeholder = "PSI/Bar" 
     cell.txtStartPressure.text = userDefault.objectForKey("startPressure") as? String 
     cell.txtStartPressure_Symbol.text = userDefault.objectForKey("symbol_startPressure") as? String 
     userDefault.synchronize() 
     return cell 

は私のDiveStartTankPressureTableViewCellは、次のようになります。

class DiveStartTankPressureTableViewCell: UITableViewCell { 

    @IBOutlet weak var lbl_Start_Pressure: UILabel! 
    @IBOutlet weak var txtStartPressure: UITextField! 
    @IBOutlet weak var txtStartPressure_Symbol: UITextField! 

    private(set) var startingTank : String? 
    private(set) var startingTankSymbol : String? 

    // --------------------------------------------------------------------------------------------- 
    // MARK: - UITableVieCell Methods 

    // 
    // Called when we are initialized from a storyboard or nib file. 
    // 
    override func awakeFromNib() 
    { 
     super.awakeFromNib() 
    } 

    // 
    // The item has been selected in the table. 
    // 
    override func setSelected(selected: Bool, animated: Bool) 
    { 
     super.setSelected(selected, animated: animated) 
    } 

    // --------------------------------------------------------------------------------------------- 
    // MARK: - UITextFieldDelegate Method Implementation 

    // 
    // We are called when the user is done editing. 
    // 
    func textFieldDidEndEditing(textField: UITextField) 
    { 
     startingTank = txtStartPressure.text 
     startingTankSymbol = txtStartPressure_Symbol.text 
     itemToParse() 
    } 

    override func encodeWithCoder(aCoder: NSCoder) { 
     aCoder.encodeObject(startingTank, forKey: "startingTank") 
     aCoder.encodeObject(startingTankSymbol, forKey: "startingTankSymbol") 
    } 

    func itemToParse() { 

     let updateDiveQuery = PFQuery(className: "divelog") 
     updateDiveQuery.whereKey("uuid", equalTo: diveUUID) 
     updateDiveQuery.getFirstObjectInBackgroundWithBlock {(objects: PFObject?, error: NSError?) -> Void in 

      if error == nil { 

       if let updateDiveObject = objects { 

        updateDiveObject["startingTank"]  = self.startingTank 
        updateDiveObject["startingTankSymbol"]  = self.startingTankSymbol 

        updateDiveObject.pinInBackground() 
        updateDiveObject.saveInBackgroundWithBlock {(done:Bool, error:NSError?) in 

         if done { 
          print ("ParseData UPDATED data saved") 

         } else { 
          updateDiveObject.saveEventually() 
         } 
        } 

        if PFUser.currentUser()!.username == nil { 
         updateDiveObject["username"] = "Not Signed in" 
        } else { 
         updateDiveObject["username"] = PFUser.currentUser()!.username 
        } 
        updateDiveObject.saveEventually() 

       } 
      } 
     } 
    } 
} 

任意のアイデアを見て?

EDIT、私のストーリーボード

enter image description here

興味深いアップデートのスクリーンショットを追加します。私は、「プレーン」とない「グループ」を試してみましたエラーは以下に変更..

Could not cast value of type 'UITableViewCell' (0x10623e278) to 'RLA_DiveLog.DiveStartTankPressureTableViewCell' (0x1022fb330). 
+0

他のプロトタイプのセルは動作していますか?もしそうなら、あなたのセル識別子のスペル&ケースを慎重にチェックしてください。 – Paulw11

+0

これはリストの最初のものなのか分かりません。 LocationCellは機能しますが、別の形式です。しかし、それはまだdequeueReusableCellWithIdentifierです。それが私を困惑させるものです。私は何度もスペルチェックをしました。 –

+0

ちょっとしたお知らせ:Parseフレームワークを使用しています。彼らのサービスは2017年1月以降に閉鎖されていることをご存知ですか? Parseサーバをバックエンドにデプロイしていない限り、あなたのアプリはそれまでには廃止されるでしょう:) – Cabus

答えて

0

は、おそらくあなたは、プロトタイプセルは下の画像を参照してください選択してAttribute inspectorを使用してtableViewsTankStartCellidentifierを設定するのを忘れ

このことができますenter image description here

・ホープ..

+0

上記の編集を参照してください。私はスクリーンショットを追加しました。識別子が設定されます。それが私がそんなに困惑している理由です。 –

+0

@DavidSanford何かが見つからない場合は、識別子の重複があるかもしれません。厳密に適用してください。 – vaibhav

+0

"ハード"に従っているかわかりません –

0

はあなたのセルが同様に右のタイプであることを確認したことがありますか?確かに

enter image description here

0

非常に奇妙1。

調査の結果、Xcodeは2つの異なるストーリーボードを利用していたようです。 Main.Storyboardをクリックしてこのストーリーボードを更新すると、ViewControllerがMain.Storyboard(Base)を使用していたので効果がありませんでした。

これはどのようになったのか分かりませんが、明らかにXcode 8の問題です。

これは、この奇妙な問題を持つ他の人に役立ちます。

関連する問題