2017-06-08 13 views
0

Text not underneathUISwitch詳細テキストの下に

ラベルの下に説明文を置くことができます。

UISwitch *toggle = [[UISwitch alloc] init]; 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Cell"]; 
    cell.textLabel.text = @"Remote Execution"; 
    cell.detailTextLabel.text = @"Remote execution will permit registered devices to execute tests without manually starting them"; 
    [cell addSubview:toggle]; 
    cell.accessoryView = toggle; 
    [cell.detailTextLabel setAlpha:1.0]; 
    [cell.detailTextLabel setTextColor:[UIColor redColor]]; 

答えて

1

利用UITableViewCellStyleSubtitle代わりのUITableViewCellStyleValue1:以下は、私がこれまで持っているコードがある働いたが、私のメッセージは下に1行の長いように思え

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"]; 
+0

。下の2行に分割する方法はありますか?ありがとう! – Parth

+0

すべてのセルに同じメッセージがありますか?それはたまには1行になることもあれば2行になることもありますか?それとも3行?デバイスが横向きに回転している場合はどうですか?最適な方法は、カスタムセルを作成し、動的高さセルに自動レイアウトを使用することです。 – DonMag

+0

私はちょうどcell.detailTextLabel.numberOfLines = 2を設定しました。 – Parth

関連する問題