This commit is contained in:
TJ Lambert 2022-01-21 14:44:09 -06:00
Родитель 9ac7c6d397
Коммит a2b18c29ce
5 изменённых файлов: 38 добавлений и 10 удалений

Просмотреть файл

@ -5,7 +5,7 @@
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<SupportedOSPlatformVersion>14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion>13.0</SupportedOSPlatformVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>

Просмотреть файл

@ -199,10 +199,8 @@ public partial class TableViewEditingViewController : UIViewController {
// Get a cell of the desired kind.
var cell = tableView.DequeueReusableCell (key) ?? new UITableViewCell (UITableViewCellStyle.Subtitle, key);
var content = cell.DefaultContentConfiguration;
content.Text = mountain.Name;
content.SecondaryText = formatter.StringFromNumber (NSNumber.FromInt32 (mountain.Height));
cell.ContentConfiguration = content;
var secondaryText = formatter.StringFromNumber (NSNumber.FromInt32 (mountain.Height));
cell.AddTextLabel (mountain.Name, secondaryText);
// Return the cell.
return cell;

Просмотреть файл

@ -153,18 +153,15 @@ public class WiFiSettingsViewController : UIViewController {
if (obj is Item item) {
// Get a cell of the desired kind.
var cell = tableView.DequeueReusableCell (key, indexPath);
var content = cell.DefaultContentConfiguration;
// network cell
if (item.IsNetwork) {
content.Text = item.Title;
cell.ContentConfiguration = content;
cell.AddTextLabel (item.Title);
cell.Accessory = UITableViewCellAccessory.DetailDisclosureButton;
cell.AccessoryView = null;
} else if (item.IsConfig) {
// configuration cells
content.Text = item.Title;
cell.ContentConfiguration = content;
cell.AddTextLabel (item.Title);
if (item.Type == ItemType.WifiEnabled) {
var enableWifiSwitch = new UISwitch { On = wifiController.WifiEnabled };

Просмотреть файл

@ -0,0 +1,8 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>", Scope = "member", Target = "~M:Conference_Diffable.UITableViewCellExtensions.AddTextLabel(UIKit.UITableViewCell,System.String,System.String)")]

Просмотреть файл

@ -0,0 +1,25 @@
namespace Conference_Diffable;
public static class UITableViewCellExtensions
{
public static void AddTextLabel (this UITableViewCell cell, string text, string secondaryText = "")
{
// Beginning in iOS 14, UITableViewCell has to use cell.ContentConfiguration
// to add text
if (UIDevice.CurrentDevice.CheckSystemVersion (14, 0))
{
var content = cell.DefaultContentConfiguration;
content.Text = text;
if (!string.IsNullOrEmpty (secondaryText))
content.SecondaryText = secondaryText;
cell.ContentConfiguration = content;
} else {
cell.TextLabel.Text = text;
if (!string.IsNullOrEmpty (secondaryText))
cell.DetailTextLabel.Text = secondaryText;
}
}
}