Xcode9 iOS11适配

1.iOS11UIToolBar上添加的按钮点击实效

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIToolbar *toolBar = [[UIToolbar alloc] init];
    toolBar.backgroundColor = [UIColor cyanColor];
    toolBar.frame = CGRectMake(0, 0, self.view.frame.size.width, 200);
    [self.view addSubview:toolBar];
    
    UIButton *button = [[UIButton alloc] init];
    button.frame = CGRectMake(0, 0, 100, 200);
    button.backgroundColor = [UIColor orangeColor];
    [button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
    [toolBar addSubview:button];
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)buttonClick {
    NSLog(@"我点击按钮了哦!!!,我真的点击了哦");
}

测试总结:iOS11一下按钮可以正常点击
iOS11以上按钮点击无法响应。
这个问题我是在修改别人代码的时候发现的。

2.iOS11 window上的视图结构发生了变化

iOS11

(lldb) po [UIApplication sharedApplication].keyWindow
; layer = >

(lldb) po [UIApplication sharedApplication].windows[0]
; layer = >

(lldb) po [UIApplication sharedApplication].windows[1]
>

(lldb) po [UIApplication sharedApplication].windows[2]
<_UIInteractiveHighlightEffectWindow: 0x10268d030; frame = (0 0; 414 736); hidden = YES; opaque = NO; userInteractionEnabled = NO; gestureRecognizers = ; layer = >

(lldb) po [UIApplication sharedApplication].windows[3]
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-4)..
The process has been returned to the state before expression evaluation.

iOS11以下

(lldb) po [UIApplication sharedApplication].keyWindow
; layer = >


(lldb) po [UIApplication sharedApplication].windows
<__NSArrayM 0x170257220>(
; layer = >
)

(lldb) po [UIApplication sharedApplication].windows[0]
; layer = >

(lldb) po [UIApplication sharedApplication].windows[1]
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-3)..
The process has been returned to the state before expression evaluation.

这个问题是在发现之前写的MBProgressHUD怎么突然不行了,在iOS11不能出现和iOS11以下可以出现

+ (MBProgressHUD *)showMessage:(NSString *)message toView:(UIView *)view {
//iOS11以下windows里面新增加了成员
//    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    if (view == nil) view = [UIApplication sharedApplication].keyWindow;
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.labelText = message;
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    // YES代表需要蒙版效果
    hud.dimBackground = YES;
    return hud;
}

你可能感兴趣的:(Xcode9 iOS11适配)