For 503aa82: it turns out iOS has stolen inputView
This commit should fix its core issue, so the workaround is removed. For a while, UITextField variable was named `inputView`, which is same as the name UIKit used to query custom input view. It was not until recently that the crash started occurring on my device. Other fixes (for LogView): - Line indentation in SurfaceViewController+LogView.m:214 - Navigation bar size: now call sizeToFit
This commit is contained in:
1 parent
8c0b8da9c3
commit
8218a28e4d
4 files changed
+17
-35
No files matched your search
@@ -85,6 +85,7 @@ static int logCharPerLine;
|
||||
UINavigationBar* navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
|
||||
navigationBar.items = @[navigationItem];
|
||||
navigationBar.topItem.title = NSLocalizedString(@"game.menu.log_output", nil);
|
||||
[navigationBar sizeToFit];
|
||||
[self.logOutputView addSubview:navigationBar];
|
||||
canAppendToLog = YES;
|
||||
[self actionStartStopLogOutput];
|
||||
@@ -210,8 +211,7 @@ static int logCharPerLine;
|
||||
|
||||
// Print last 100 lines from latestlog.txt
|
||||
for (int i = MAX(lines.count-100, 0); i < lines.count; i++) {
|
||||
|
||||
[self _appendToLog:lines[i]];
|
||||
[self _appendToLog:lines[i]];
|
||||
}
|
||||
|
||||
fatalErrorOccurred = YES;
|
||||
|
||||
@@ -45,7 +45,7 @@ BOOL slideableHotbar;
|
||||
|
||||
@property(nonatomic) UIView *ctrlView;
|
||||
|
||||
@property(nonatomic) TrackedTextField *inputView;
|
||||
@property(nonatomic) TrackedTextField *inputTextField;
|
||||
@property(nonatomic) NSMutableDictionary* cc_dictionary;
|
||||
@property(nonatomic) NSMutableArray* swipeableButtons;
|
||||
@property(nonatomic) ControlButton* swipingButton;
|
||||
@@ -163,16 +163,16 @@ BOOL slideableHotbar;
|
||||
self.mousePointerView.userInteractionEnabled = NO;
|
||||
[self.rootView addSubview:self.mousePointerView];
|
||||
|
||||
self.inputView = [[TrackedTextField alloc] initWithFrame:CGRectMake(0, -32.0, self.view.frame.size.width, 30.0)];
|
||||
self.inputTextField = [[TrackedTextField alloc] initWithFrame:CGRectMake(0, -32.0, self.view.frame.size.width, 30.0)];
|
||||
if (@available(iOS 13.0, *)) {
|
||||
self.inputView.backgroundColor = UIColor.secondarySystemBackgroundColor;
|
||||
self.inputTextField.backgroundColor = UIColor.secondarySystemBackgroundColor;
|
||||
} else {
|
||||
self.inputView.backgroundColor = UIColor.groupTableViewBackgroundColor;
|
||||
self.inputTextField.backgroundColor = UIColor.groupTableViewBackgroundColor;
|
||||
}
|
||||
self.inputView.delegate = self;
|
||||
self.inputView.font = [UIFont fontWithName:@"Menlo-Regular" size:20];
|
||||
self.inputView.clearsOnBeginEditing = YES;
|
||||
self.inputView.textAlignment = NSTextAlignmentCenter;
|
||||
self.inputTextField.delegate = self;
|
||||
self.inputTextField.font = [UIFont fontWithName:@"Menlo-Regular" size:20];
|
||||
self.inputTextField.clearsOnBeginEditing = YES;
|
||||
self.inputTextField.textAlignment = NSTextAlignmentCenter;
|
||||
|
||||
NSString *controlFilePath = [NSString stringWithFormat:@"%s/controlmap/%@", getenv("POJAV_HOME"), (NSString *)getPreference(@"default_ctrl")];
|
||||
|
||||
@@ -216,7 +216,7 @@ BOOL slideableHotbar;
|
||||
[ControllerInput registerControllerCallbacks:GCController.controllers.firstObject];
|
||||
}
|
||||
|
||||
[self.rootView addSubview:self.inputView];
|
||||
[self.rootView addSubview:self.inputTextField];
|
||||
|
||||
|
||||
[self performSelector:@selector(initCategory_LogView)];
|
||||
@@ -628,13 +628,13 @@ int currentVisibility = 1;
|
||||
switch (keycode) {
|
||||
case SPECIALBTN_KEYBOARD:
|
||||
if (held == 0) {
|
||||
if (self.inputView.isFirstResponder) {
|
||||
[self.inputView resignFirstResponder];
|
||||
self.inputView.alpha = 1.0f;
|
||||
if (self.inputTextField.isFirstResponder) {
|
||||
[self.inputTextField resignFirstResponder];
|
||||
self.inputTextField.alpha = 1.0f;
|
||||
} else {
|
||||
[self.inputView becomeFirstResponder];
|
||||
[self.inputTextField becomeFirstResponder];
|
||||
// Insert an undeletable space
|
||||
self.inputView.text = @" ";
|
||||
self.inputTextField.text = @" ";
|
||||
inputTextLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ extern bool isUseStackQueueCall;
|
||||
return range;
|
||||
}
|
||||
|
||||
- (id) replaceRangeWithTextWithoutClosingTyping:(UITextRange *)range replacementText:(NSString *)text
|
||||
- (id)replaceRangeWithTextWithoutClosingTyping:(UITextRange *)range replacementText:(NSString *)text
|
||||
{
|
||||
int length = [super offsetFromPosition:range.start toPosition:range.end];
|
||||
|
||||
|
||||
@@ -37,24 +37,6 @@ __attribute__((constructor)) void hookConstructor(void) {
|
||||
|
||||
@end
|
||||
|
||||
@implementation UIResponder(hook)
|
||||
|
||||
- (BOOL)hook_becomeFirstResponder {
|
||||
// Workaround a weird bug: UIKit tries to present an accessibility UITextField
|
||||
// for some reason, which could cause crash due to mismatched parent view controller
|
||||
// UIViewControllerHierarchyInconsistency
|
||||
|
||||
@try {
|
||||
return [self hook_becomeFirstResponder];
|
||||
} @catch (NSException *e) {
|
||||
NSLog(@"-[UITextInputUIResponderAccessibility becomeFirstResponder]: %@", e);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation UITraitCollection(hook)
|
||||
|
||||
- (UIUserInterfaceSizeClass)verticalSizeClass {
|
||||
|
||||
Reference in new issue
Block a user