簡體   English   中英

TableView覆蓋View中的整個屏幕

[英]TableView Covering up whole screen in View

我在添加到ViewController的TableView遇到了麻煩。 問題是它吞噬了整個黑色的屏幕,從而隱藏了其他所有內容。

這就是我想要的,但是我得到了這些

這是受約束的水平中心和頂部距離最近的鄰居

這沒有任何限制。 可以看到表格和單元格,但它阻塞了其他所有內容。

下面是我的ViewController的代碼。 我想知道TableView的行為如何以及如何對其進行修復,以便在第一張圖片中獲得所需的結果。

class WalletViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

@IBOutlet weak var lblWalletAddress: UILabel!
@IBOutlet var tableViewAssets: UITableView!

var balance: [Balance] = []
var wallet = Wallet()

override func viewDidLoad()
{
    super.viewDidLoad()
    self.title = "Wallet Details"

    self.tableViewAssets.delegate = self
    self.tableViewAssets.dataSource = self
}

public func numberOfSections(in tableView: UITableView) -> Int
{
    return 1
}

public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
    return wallet.balance.count
}

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
    let tableCell = tableView.dequeueReusableCell(withIdentifier: "AssetTableCell")// as! AssetTableViewCell
    let assetTableCell = tableCell as! AssetTableViewCell

    assetTableCell.lblAssetName.text = wallet.balance[indexPath.row].asset
    assetTableCell.lblAssetAmount.text = String(wallet.balance[indexPath.row].amount)

    return assetTableCell
}

我已經解決了 顯然是因為默認的背景顏色是黑色,我不得不使用Xcode的“建議約束”使所有內容與TableView一起使用。 @nivritgupta是正確的。 謝謝!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM