2016-09-07 9 views
1

私はグループ化されたテーブルビューを持つビューコントローラを持っています。これにより、非常に奇妙なグリッチが生成され、セクションのタイトルが横に表示されます。私はテーブルビューのスーパービューにトップ、トレーリング、ボトム、リーディングの制約を付けました。cellForRowAtIndexPathでUITableViewCell()を返してテストしましたが、問題の原因となっていたセルであるかどうかを確認しましたが、 。時間後UITableViewセクションタイトルGlitch?

var sectionTitles = ["Customer Orders", "Unprocessed Orders", "Processed Orders"] 


func numberOfSectionsInTableView(tableView: UITableView) -> Int { 
    return sectionTitles.count 
} 

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 
    return 1 
} 

func sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? { 
    return sectionTitles 
} 

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ 
    let cell = tableView.dequeueReusableCellWithIdentifier(CONSTANTS.CELL_IDENTIFIERS.ORDER_CELL) as! OrderTableViewCell 
    return cell 
} 

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 
    // Perform segue to order list in future 
} 

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { 
    return 117.0 
} 

enter image description here

答えて

0

私はあなたが多くのタイトルを入れていないだけで一つのセクションを持っている場合、私は

override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 
    return sectionTitles[section] 
} 
0
func sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? { 
    return sectionTitles 
} 

このメソッドを実装していなかったことを考え出しました。代わりに、あなたは、各セルのタイトルを与えたい場合 あなたのカスタマイズされたtableViewCellにして、ラベルを追加する必要があり、あなたのcellForRowAtIndexPath(あなたがNSObjectクラスを作成した後で)あなたはこのような何かを置く必要があります:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{ 
    let cell = tableView.dequeueReusableCellWithIdentifier(CONSTANTS.CELL_IDENTIFIERS.ORDER_CELL) as! OrderTableViewCell 

let order = Order[indexPath.row] 

cell.yourTitleLabel.text = order.title 

    return cell 
} 
関連する問題