2016-05-06 10 views
2

何らかの理由で、フッターとして動作するのではなく、フッターがテーブルの下に重なって表示されます。あなたが見ることができるようにこれは最も可能性の高い自動レイアウトフッタービューはUITableViewの下部に貼り付かず、代わりにテーブルをオーバーラップします(自動レイアウトの問題)

var coreView = UIView() //This is the footer 
var postBody = UILabel() //This is the label, which will determine the height of the footer. 

let nib = UINib(nibName: "MessagesTableViewCell", bundle: nil) 
    let 

nibSimple = UINib(nibName: "SimpleMessagesTableViewCell", bundle: nil) 
self.tableView.registerNib(nib, forCellReuseIdentifier: "MessagesTableViewCell") 
self.tableView.registerNib(nibSimple, forCellReuseIdentifier: "SimpleMessagesTableViewCell") 
self.tableView.dataSource = self 
self.tableView.delegate = self 
self.tableView.rowHeight = UITableViewAutomaticDimension 
self.tableView.estimatedRowHeight = 100.0 
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None 
self.tableView.separatorColor = UIColor(hex: 0xf5f5f5) 
self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0) 
self.tableView.clipsToBounds = true 
self.tableView.allowsMultipleSelection = false 
self.tableView.keyboardDismissMode = .OnDrag 


    coreView.backgroundColor = UIColor.yellowColor() 

    //Create Label and add it to the footer 
    postBody.text = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog." 
    postBody.font = UIFont(name: "Roboto-Regular", size: 16.0) 
    postBody.lineBreakMode = .ByWordWrapping 
    postBody.numberOfLines = 0 
    postBody.backgroundColor = FlatLime() 
    coreView.addSubview(postBody) 

    //Enable constraints for footer and label 
    postBody.translatesAutoresizingMaskIntoConstraints = false 
    coreView.translatesAutoresizingMaskIntoConstraints = false 

    //Add constraints to the footer and post body 
    let postBodyLeadingConstraint = NSLayoutConstraint(item: postBody, attribute: NSLayoutAttribute.Leading, relatedBy: NSLayoutRelation.Equal, toItem: coreView, attribute: NSLayoutAttribute.Leading, multiplier: 1, constant: 0) 
    postBodyLeadingConstraint.active = true 

    let postBodyTrailingConstraint = NSLayoutConstraint(item: postBody, attribute: NSLayoutAttribute.Trailing, relatedBy: NSLayoutRelation.Equal, toItem: coreView, attribute: NSLayoutAttribute.Trailing, multiplier: 1, constant: 0) 
    postBodyTrailingConstraint.active = true 

    let postBodyTopConstraint = NSLayoutConstraint(item: postBody, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: coreView, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0) 
    postBodyTopConstraint.active = true 

    let postBodyBottomConstraint = NSLayoutConstraint(item: postBody, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: coreView, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0) 
    postBodyBottomConstraint.active = true 

    postBody.preferredMaxLayoutWidth = screenWidth 
    self.tableView.tableHeaderView = UIView(frame: CGRectZero) 
    self.tableView.tableFooterView = coreView 

、自動レイアウトは、(ラベルの高さに基づいて)フッタービューの高さを決定するために動作します。 しかし、これが結果です。フッタは最後の行のフッタビューintとして設定していますが、テーブルを「オーバーラップ」します。

また、coreViewの右側に白い空白がある理由は誰にも分かりますか?

footer overlaps table

答えて

0

グループにUITableViewStyleを変更しようとしない理由は、私はそれが働いていたと思います。

0

top、leadingとwidthの制約を持つpostBodyは、この問題を解決する可能性があります。

関連する問題