iOS 13 适配问题反馈
xiaohange opened this issue · comments
ios13多处卡死
searchTextField为空崩溃
PYSearchViewController
处Client error attempting to change layout margins of a private view’
相同的问题,求修复
没人维护了吗
@xiaohange 麻烦能录个视频或者复现路径说下嘛 我这边测试没有发现问题
更改色值应该就可以看出具体的问题了。
搜索框的UI样式,跟之前的发生了变化,圆角的弧度,光标的颜色,字体的大小。
#define HexRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
这个是设置的颜色
searchViewController.searchBarBackgroundColor = HexRGB(0x000000); searchViewController.searchSuggestionView.backgroundColor = HexRGB(0x2D2D2D); searchViewController.view.backgroundColor = HexRGB(0x2D2D2D); searchViewController.searchTextField.textColor = HexRGB(0x9B9B9B);
遇到相同的问题,求修复
iOS 麻烦大家有问题在这里列举反馈哈
自己回复吧,在iOS13里边UISearchBar自带searchTextField,所以在PYVc的内部里边需要增加iOS13的兼容,如果不想调整的话,可以在外边进行样式的设置。
例如:
PYSearchViewController *searchViewController = [PYSearchViewController searchViewControllerWithHotSearches:strArr searchBarPlaceholder:@"搜索内容" didSearchBlock:^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) {
}];
// 3. Set style for popular search and search history
searchViewController.hotSearchStyle = PYHotSearchStyleBorderTag;
searchViewController.searchHistoryStyle = PYHotSearchStyleDefault;
searchViewController.removeSpaceOnSearchString = NO;
if (@available(iOS 13, *)) {
NSMutableAttributedString *arrStr = [[NSMutableAttributedString alloc]initWithString:searchViewController.searchBar.searchTextField.placeholder attributes:@{NSForegroundColorAttributeName : HexRGB(0x9B9B9B) ,NSFontAttributeName:[UIFont systemFontOfSize:13]}];
searchViewController.searchBar.searchTextField.attributedPlaceholder = arrStr;
searchViewController.searchBar.searchTextField.textColor = HexRGB(0x9B9B9B);
searchViewController.searchBar.layer.cornerRadius = 15;
searchViewController.searchBar.layer.masksToBounds = YES;
searchViewController.searchBar.searchTextField.backgroundColor = HexRGB(0x000000);
searchViewController.searchBar.searchTextField.textColor = HexRGB(0x9B9B9B);
searchViewController.searchBar.searchTextField.tintColor = [UIColor whiteColor];
searchViewController.searchBar.searchTextField.font = [UIFont systemFontOfSize:13];
}
iOS 13 设置searchTextField样式,会出现崩溃的问题,模态弹出的样子也注意一下。希望能够维护一下。
iOS13,设置searchTextField和cancelButton崩溃,提示是nil
iOS 13可直接获取searchBar的searchTextField,遍历不到了!暂时用这个解决吧!
if (@available(iOS 13, *)) {
_searchTextField = searchBar.searchTextField;
}
else {
for (UIView *subView in [[searchBar.subviews lastObject] subviews]) {
if ([[subView class] isSubclassOfClass:[UITextField class]]) {
UITextField *textField = (UITextField *)subView;
textField.font = [UIFont systemFontOfSize:16];
_searchTextField = textField;
break;
}
}
}
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchViewController];
[self presentViewController:nav animated:YES completion:nil];
开启了联想~
上面的操作会使界面卡死, 报错如下:
[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
<NSAutoresizingMaskLayoutConstraint:0x600001ca32f0 UISearchBar:0x7f8388e4a840.(null) == 2>,
<NSLayoutConstraint:0x600001ca4c30 UISearchBar:0x7f8388e4a840.left == UIView:0x7f8388e4a6e0.left>,
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600001ca4c30 UISearchBar:0x7f8388e4a840.left == UIView:0x7f8388e4a6e0.left>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
Made a possible fix in my fork xiao99xiao@243a976
Made a possible fix in my fork xiao99xiao@243a976
Thanks!
@xiao99xiao 我试了试你那个方法, 模拟器还是会卡到这个界面, 界面会卡死不能交互
@xiaohange 你那个卡死大概率不是那个constraint导致的。你先fullscreen present看看还会不会卡死。
@xiaohange 你那个卡死大概率不是那个constraint导致的。你先fullscreen present看看还会不会卡死。
找到原因了, 你那个修复是有效的, 卡死的原因是 IQKeyboardManager
的 bug, IQKeyboardManager 引起的 _textfieldText
无法输入, 再次表示感谢!
@xiaohange 你那个卡死大概率不是那个constraint导致的。你先fullscreen present看看还会不会卡死。
找到原因了, 你那个修复是有效的, 卡死的原因是
IQKeyboardManager
的 bug, IQKeyboardManager 引起的_textfieldText
无法输入, 再次表示感谢!
我也用到了IQKeyboardManager,请问这个Bug怎么解决的?
@blmyself 自己对PYSearchViewController禁用IQKeyboardManager应该就好了。
参看IQKeyboardManager的README https://github.com/hackiftekhar/IQKeyboardManager/blob/master/README.md
If IQKeyboardManager conflicts with other third-party library, then it's developer responsibility to enable/disable IQKeyboardManager when presenting/dismissing third-party library UI. Third-party libraries are not responsible to handle IQKeyboardManager.
ios13崩溃遍历不到的问题可以这么样遍历
if (@available(iOS 13, *)) {
for (id subView1 in [searchBar subviews]) {
for (id subView2 in [subView1 subviews]) {
for (id subView3 in [subView2 subviews]) {
if ([subView3 isKindOfClass:[UITextField class]]) {
UITextField *textField = (UITextField *)subView3;
textField.backgroundColor = [UIColor colorWithHex:@"#F6F6F6"];
textField.font = FONT(14);
textField.layer.cornerRadius = 32/2;
textField.layer.masksToBounds = YES;
_searchTextField = textField;
break;
}
}
}
}
}else{
for (UIView *subView in [[searchBar.subviews lastObject] subviews]) {
if ([[subView class] isSubclassOfClass:[UITextField class]]) {
UITextField *textField = (UITextField *)subView;
textField.backgroundColor = [UIColor colorWithHex:@"#F6F6F6"];
textField.font = FONT(14);
textField.layer.cornerRadius = 32/2;
textField.layer.masksToBounds = YES;
_searchTextField = textField;
break;
}
}
}
@blmyself 自己对PYSearchViewController禁用IQKeyboardManager应该就好了。
参看IQKeyboardManager的README https://github.com/hackiftekhar/IQKeyboardManager/blob/master/README.mdIf IQKeyboardManager conflicts with other third-party library, then it's developer responsibility to enable/disable IQKeyboardManager when presenting/dismissing third-party library UI. Third-party libraries are not responsible to handle IQKeyboardManager.
禁用了也还是卡死的,还有别的解决方法么?