You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Delegate Event handler" on native objects aren't invoked #24262
After updating to .NET10 GA and the Xcode 26.1 workload, some event handlers that forward Delegate events aren't invoked any more. The problem did not happen on .NET10 RC2 with Xcode 26.0.
I noticed this on iOS for UIDocumentPickerViewController and on macOS for NSTextField, but more classes might be affected
var field = new NSTextField();
field.Changed += (_, _) => System.Diagnostics.Debugger.Break();
NOTE: The problem does not happen when debugging a macOS app or an iOS app on the simulator.
However, the problem does happen when the macOS app has been built in Release mode or the iOS app runs on a physical device.
Did you find any workaround?
When setting the delegate myself and implementing the delegate method, this works as expected
Could you please share code sample how do you make working workaround? I need on my app asap workaround for Editor TextChanged event.
This is gen AI generated code I'm trying to test
using Foundation;
using Microsoft.Maui.Handlers;
using UIKit;
namespace YourNamespace;
public partial class CustomEditorHandler : EditorHandler
{
private TextViewDelegate? _delegateRef;
protected override void ConnectHandler(UITextView platformView)
{
base.ConnectHandler(platformView);
// Keep strong reference so linker/GC doesn't eat it in Release
_delegateRef = new TextViewDelegate(this);
// Override any existing delegate
platformView.Delegate = _delegateRef;
}
protected override void DisconnectHandler(UITextView platformView)
{
if (platformView.Delegate == _delegateRef)
platformView.Delegate = null;
_delegateRef = null;
base.DisconnectHandler(platformView);
}
private sealed class TextViewDelegate : UITextViewDelegate
{
private readonly CustomEditorHandler _handler;
public TextViewDelegate(CustomEditorHandler handler)
{
_handler = handler;
}
// Called every time text actually changes
public override void Changed(UITextView textView)
{
var virtualView = _handler.VirtualView;
if (virtualView is null)
return;
// Sync platform -> virtual view
if (virtualView.Text != textView.Text)
{
virtualView.Text = textView.Text;
// Notify MAUI the Text property has updated
_handler.UpdateValue(nameof(Editor.Text));
}
}
// Optional: if you need to intercept keystrokes before they apply
public override bool ShouldChangeText(UITextView textView, NSRange range, string text)
{
// You can add custom logic here if needed.
// Returning true allows the change.
return true;
}
}
}
Oh thanks you, but I've found already workaround. (btw above delegate override was throwing exception). Override InsertText worked on release build, only had to create custom event on my customeditor and raise from there.
public class UIBackwardsTextView : MauiTextView
{
private readonly CustomEditor _virtualView;
public UIBackwardsTextView(IEditor virtualView)
{
_virtualView = virtualView as CustomEditor;
}
public override void InsertText(string text)
{
base.InsertText(text);
_virtualView.RaiseCustomText(text);
}
}
Activity
rolfbjarne commentedon Nov 17, 2025
I can reproduce this, and I'll have a look.
tipa commentedon Nov 17, 2025
Thanks! If it helps tracking down the issue,
UITabBarControllerDelegateevents appears to be affected as wellhflexgrig commentedon Nov 17, 2025
Could you please share code sample how do you make working workaround? I need on my app asap workaround for Editor TextChanged event.
This is gen AI generated code I'm trying to test
rolfbjarne commentedon Nov 17, 2025
Adding this to the csproj should work around it:
hflexgrig commentedon Nov 17, 2025
Oh thanks you, but I've found already workaround. (btw above delegate override was throwing exception). Override InsertText worked on release build, only had to create custom event on my customeditor and raise from there.
[src] Make sure to add [DynamicDependency] attributes to members on i…
Revert "[src] Make sure to add [DynamicDependency] attributes to memb…
[src] Add a [DynamicDependency] attribute from the event field to exp…
[src] Add a [DynamicDependency] attribute from the event field to exp…
[release/10.0.1xx] [src] Add a [DynamicDependency] attribute from the…
[src] Add a [DynamicDependency] attribute from the event field to exp…
nvgogh commentedon Dec 3, 2025
Perfect. Thank you very much. This also solved other issues I had on the same page (like scroll not working)
[bgen] Preserve all public methods supporting protocol methos as even…
[bgen] Preserve all public methods supporting protocol methos as even…
[bgen] Preserve all public methods supporting protocol methos as even…
[release/10.0.1xx] [bgen] Preserve all public methods supporting prot…