0

私は(contentOffsetを設定して)tableViewを上に移動し、特定の(ここでは行番号1)セルの高さを同時に変更しています。そのため、アニメーションが不安定になり、tableViewがデフォルトの位置に戻ります(は望ましくない動作です)

私のコード:

func keyboardWillShow(notification:NSNotification) {
    let userInfo:NSDictionary = notification.userInfo!
    let keyboardFrame:NSValue = userInfo.valueForKey(UIKeyboardFrameEndUserInfoKey) as! NSValue
    let keyboardRectangle = keyboardFrame.CGRectValue()
    let  duration = (notification.userInfo![UIKeyboardAnimationDurationUserInfoKey] as! Double)

    keyboardHeight = keyboardRectangle.height
    accurateheight = accurateheight - (keyboardHeight + inputToolbar.frame.size.height) // accurateHeight is the desired CGFloat value that i want
    self.tableView.beginUpdates()
    self.tableView.endUpdates()

    let frame = tableView.rectForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))
    defaultRowHeight = frame.height
    let cgpoint = CGPointMake(0, (CGFloat(-64 + defaultRowHeight)))

        self.tableView.setContentOffset(cgpoint, animated: true) // here i'm moving up my tableView 


}

私の中でheightForRowAtIndexPath

    override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {

    if indexPath.row == 0 {
            return  44
    }else {
          return accurate height // cell's height which i'm changing
    }
}

また、次のように特定の行(高さを変更しているもの)のみを更新しようとしました:

var indexPath = NSIndexPath(forRow: 1, inSection: 0)
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Top)

しかし、上記は機能しませんでしたが、キーボードがポップアップしないこともありました。

tableView を移動 (上にスクロール) し、同時にセルの高さを変更するにはどうすればよいですか?? どんな手掛かり ?

4

0 に答える 0