UE4 IOS 原生输入框弹出框问题
如果打开IOS原生弹出框
不勾选这个选项就会自动弹出IOS原生弹框,优点是可以进行复制粘贴之类的
UE4.26.2,我的项目中未勾选了这个选项会出现了弹出框并且如果弹出框中如果原本有内容,点击之后会出现Crash
解决方案:参考Unreal 论坛中发现了类似的解决方案以及方法,在Mac上通过修改源码引擎来解决,具体修改如下:
\Engine\Source\Runtime\Slate\Public\Framework\Text\IOS\IOSPlatformTextField.h 33行
@interface SlateTextField : UIAlertController
{
TWeakPtr<IVirtualKeyboardEntry> TextWidget;
FText TextEntry;
bool bTransitioning;
bool bWantsToShow;
//- NSString* CachedTextContents;
//- NSString* CachedPlaceholderContents;
NSMutableString* CachedTextContents; //+
NSMutableString* CachedPlaceholderContents; //+
\Engine\Source\Runtime\Slate\Private\Framework\Text\IOS\IOSPlatformTextField.cpp 186 行
-(void)show:(TSharedPtr<IVirtualKeyboardEntry>)InTextWidget text:(NSString*)TextContents placeholder:(NSString*)PlaceholderContents keyboardConfig:(FKeyboardConfig)KeyboardConfig
{
TextWidget = InTextWidget;
TextEntry = FText::FromString(TEXT(""));
//- if(CachedTextContents != nil)
//- {
//- [CachedTextContents release];
//- }
//- if(CachedPlaceholderContents != nil)
//- {
//- [CachedPlaceholderContents release];
//- }
[CachedTextContents setString : TextContents] ; //+
[CachedPlaceholderContents setString : PlaceholderContents] ; //+
//- CachedTextContents = [TextContents copy]; // This is the line that throws the error
//- CachedPlaceholderContents = [PlaceholderContents copy];
CachedKeyboardConfig = KeyboardConfig;
bWantsToShow = true;
以及 144行
-(void)hide
{
bWantsToShow = false;
if(CachedTextContents != nil)
{
//- [CachedTextContents release];
CachedTextContents = nil;
}
if(CachedPlaceholderContents != nil)
{
//- [CachedPlaceholderContents release];
CachedPlaceholderContents = nil;
}