2017-02-23 10 views
1

内部に2つのテキストラベルを持つUITableViewがあります。 少し動かしたい。テキストと詳細テキストラベル(ios、xamarin)間のUITableViewパディング

私は全体のセルの高さのプロパティを見つけましたが、探していないものはありません。

私はどんなことができますか?ここ

コードは次のとおりです。

using System; 
using UIKit; 
using System.Collections.Generic; 

namespace iOSInputOutput 
{ 
    public class TableSource : UITableViewSource 
    { 

     List<string> gameNamesList; 
     List<string> gameIdsList; 

     string cellIdentifier = "TableCell"; 

     public TableSource(List<string> games, List<string> ids) 
     { 
      gameNamesList = games; 
      gameIdsList = ids; 
     } 

     public override nint RowsInSection(UITableView tableview, nint section) 
     { 
      return gameIdsList.Count; 
     } 

     public override UITableViewCell GetCell(UITableView tableView, Foundation.NSIndexPath indexPath) 
     { 
      UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier); 
      //recucle cells that away from vision on screen 

      if (cell == null) 
       cell = new UITableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier); 
      cell.TextLabel.Text = gameNamesList[indexPath.Row]; 


      cell.DetailTextLabel.Text = gameIdsList[indexPath.Row]; 

      //tableView.RowHeight = (nfloat) 124.0; 

      return cell; 
     } 
    } 
} 

答えて

0

カスタムUITableViewCellのと場所のラベルを作成する必要がありますが、その中に望むように、りんごのデフォルトのUITableViewCellを操作しようとしないでください...

だけのUITableViewCellのサブクラス

class CustomCell: UITableViewCell { 

let titleLabel: UILabel = { 
    let myVar = UILabel() 
    myVar.font = UIFont.systemFont(ofSize: 20) 
    return myVar 
}() 

let detailLabel: UILabel = { 
    let myVar = UILabel() 
    myVar.font = UIFont.systemFont(ofSize: 20) 
    return myVar 
}() 

override init(style: UITableViewCellStyle, reuseIdentifier: String?) { 
    super.init(style: style, reuseIdentifier: reuseIdentifier) 
    self.contentView.addSubview(titleLabel) 
    self.contentView.addSubview(detalLabel) 
    self.setUp() 
} 

required init?(coder aDecoder: NSCoder) { 
    fatalError("init(coder:) has not been implemented") 
} 

func setUp() { 

    // here you do what you want with your labels (position them as you like) 

} 
} 
+0

ありがとう、ここではxamarinの回答を得るのは難しいです。 は非常に珍しいプラットフォームやidkのように思えるのですが、なぜ起こるのですか? – Vadim

+0

誰もがXcodeを使用しているので、setUp()でそれらを移動するには – user3466447

+0

btwでしょうか? – Vadim

関連する問題