Skip to content

Commit

Permalink
Fixed iOS cell height by removing GetHeightForRow() from NativeAutoSu…
Browse files Browse the repository at this point in the history
…ggestBox and upgraded from UITableViewCell.TextLabel to UIContentConfiguration.Text.
  • Loading branch information
davefxy committed May 31, 2023
1 parent df81907 commit 92f4f3c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion AutoSuggestBox/Handlers/AutoSuggestBoxHandler.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#nullable enable
using Microsoft.Maui.Handlers;
using Maui.AutoSuggestBox.Platforms.iOS;
using Microsoft.Maui.Platform;
using System.Drawing;
using UIKit;

Expand Down
18 changes: 5 additions & 13 deletions AutoSuggestBox/Handlers/NativeAutoSuggestBox.iOS.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using CoreGraphics;
using Foundation;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Platform;
using System.Runtime.InteropServices;
using UIKit;

namespace Maui.AutoSuggestBox.Platforms.iOS
Expand Down Expand Up @@ -334,12 +332,11 @@ public override UITableViewCell GetCell(UITableView tableView, NSIndexPath index

var item = _items.ElementAt(indexPath.Row);

cell.TextLabel.Text = _labelFunc(item);
#pragma warning disable CA1416
//var config = cell.DefaultContentConfiguration;
//config.Text = _labelFunc(item);
//cell.ContentConfiguration = config;
#pragma warning restore CA1416
var content = cell.DefaultContentConfiguration;
content.Text = _labelFunc(item);
cell.ContentConfiguration = content;
cell.AutomaticallyUpdatesContentConfiguration = false;

return cell;
}

Expand All @@ -353,11 +350,6 @@ public override nint RowsInSection(UITableView tableview, nint section)
return _items.Count();
}

public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
return 30f;
}

public event EventHandler<TableRowSelectedEventArgs<T>> TableRowSelected;

private void OnTableRowSelected(NSIndexPath itemIndexPath)
Expand Down
5 changes: 5 additions & 0 deletions SampleApp/SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">31.0</TargetPlatformMinVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net7.0-ios'">
<CodesignKey>Apple Development: Created via API (963LV775Z4)</CodesignKey>
<CodesignProvision>VS: WildCard Development</CodesignProvision>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
Expand Down

0 comments on commit 92f4f3c

Please sign in to comment.