Open DavidHathway opened 3 years ago
@DavidHathway
Could you try the following manual binding?
[System.Runtime.InteropServices.DllImport("/usr/lib/libobjc.dylib", EntryPoint = "objc_msgSend")]
public extern static void void_objc_msgSend_nfloat(IntPtr receiver, IntPtr selector, nfloat arg1);
public override void ViewDidLoad()
{
base.ViewDidLoad();
void_objc_msgSend_nfloat(UITableView.Appearance.Handle, ObjCRuntime.Selector.GetHandle("setSectionHeaderTopPadding:"), 0);
in your app, and see if it works. I don't have a table view app handy to see if it works (but it doesn't crash at least).
@chamons Thanks for your response. I ran your void_objc_msgSend_nfloat()
call in AppDelegate's FinishedLaunching()
method, and it appears to have done the trick. That will make a good workaround for now – much appreciated.
Is there a plan to include this new UITableView.Appearance.SectionHeaderTopPadding = 0.0f property in Xamarin bindings? :)
Is there a plan to include this new UITableView.Appearance.SectionHeaderTopPadding = 0.0f property in Xamarin bindings? :)
Mostly likely it is not, sectionHeaderTopPadding
is not marked with UI_APPEARANCE_SELECTOR
in UITableView.h file, so "officially" it is not part of table appearance protocol.
Suggested Addition
In XCode 13, the new
sectionHeaderTopPadding
property was added to UITableView objects for iOS 15+. While this property is now accessible directly in the UITableView class in the most recent update of Xamarin in Visual Studio, it is not possible to set the its default value across all UITableView objects using theUITableView.Appearance
property, even though the equivalent is now available in XCode.The reason I ask for this to be added is that the default value for this new property is non-zero, which means any UITableView objects will by default have ugly extra padding added on iOS 15 devices, and in applications with many UITableView objects it would be far simpler and safer to be able to set a default
sectionHeaderTopPadding
value for all of them in one place (e.g. in AppDelegate) rather than having to manually add lines of code to change that property for each one separately.Environment
Xamarin.iOS and Xamarin.Mac SDK (in Visual Studio for Windows), currently v15.0.0.8
Example Code
In XCode 13 I can set the default
sectionHeaderTopPadding
value across the whole app to zero by putting the following Swift code in e.g. AppDelegate:I would like to be able to achieve the same in Xamarin (in Visual Studio for Windows) by being able to call e.g. (in C#):
which currently is not supported.