相关疑难解决方法(0)

从Xcode 8和iOS10开始,viewDidLayoutSubviews上的视图大小不正确

似乎在Xcode 8上viewDidLoad,所有viewcontroller子视图都具有相同的1000x1000大小.奇怪的是,但没关系,viewDidLoad从来没有一个正确调整视图大小的好地方.

但是viewDidLayoutSubviews!

在我当前的项目中,我尝试打印按钮的大小:

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    NSLog(@"%@", self.myButton);
}
Run Code Online (Sandbox Code Playgroud)

日志显示myButton的大小为(1000x1000)!然后,如果我登录按钮单击,例如,日志显示正常大小.

我正在使用autolayout.

这是一个错误吗?

ios autolayout ios10 xcode8

91
推荐指数
5
解决办法
3万
查看次数

clipsToBounds导致UIImage无法在iOS10和XCode 8中显示

我将我的项目转换为iOS 10和XCode 8的新测试版.在我使用的应用程序的所有三个区域中:

imageView.layer.cornerRadius = imageView.frame.size.width/2
imageView.clipsToBounds = true
Run Code Online (Sandbox Code Playgroud)

相关图像根本不显示.我尝试清理项目以及构建文件夹,重新启动设备,尝试各种模拟器,重新添加imageView,以编程方式设置关联,UIImage而不是从资产中选择一个.

卸下clipsToBounds线示出了矩形图像无论masksToBoundstruefalse.如何在XCode8/iOS10中制作圆形图像?

编辑:该项目是Swift 2.x,尚未更新为Swift 3.0语法.

uiimageview uiimage ios ios10 xcode8

28
推荐指数
2
解决办法
9212
查看次数

Autolayout在iOS 10中没有动画效果,但在iOS 9中运行良好

- (IBAction)btnA:(id)sender {
    if(self.height.constant == 300) {
         self.height.constant = 50;
    } else {
         self.height.constant = 300;
    }

    [self.subView1 setNeedsUpdateConstraints];

    [UIView animateWithDuration:1.0 animations:^{
        [self.subView1 layoutIfNeeded];
    }];
}
Run Code Online (Sandbox Code Playgroud)

我正在使用这个代码,但iOS10它没有动画它只是跳跃增加和减少mySubview1高度.为什么?

相同的代码工作正常 iOS9

objective-c uiview ios autolayout ios-autolayout

3
推荐指数
1
解决办法
1584
查看次数

iOS 10中的动画错误

从iOS 10开始,我注意到动画布局更改(layoutIfNeeded())不是动画.这是我的UIView扩展,在iOS 9及更低版本上运行良好.

func slideIn(from edgeConstraint: NSLayoutConstraint, withDuration duration: Double = 0.25, finishedAnimating: (() -> Void)? = nil) {
    dispatch_async(dispatch_get_main_queue()) {
        edgeConstraint.constant = 0
        UIView.animateWithDuration(duration,
            delay: 0.0,
            options: .BeginFromCurrentState,
            animations: { self.layoutIfNeeded() },
            completion: { didComplete in
                finishedAnimating?()
        })
    }
}

func slideOut(from edgeConstraint: NSLayoutConstraint, withDuration duration: Double = 0.25, finishedAnimating: (() -> Void)? = nil) {
    dispatch_async(dispatch_get_main_queue()) {
        edgeConstraint.constant = -self.frame.height
        UIView.animateWithDuration(duration,
            delay: 0.0,
            options: .BeginFromCurrentState,
            animations: { self.layoutIfNeeded() },
            completion: { didComplete in
                finishedAnimating?()
        })
    } …
Run Code Online (Sandbox Code Playgroud)

animation constraints ios swift ios10

1
推荐指数
1
解决办法
2567
查看次数