草庐IT

ios - 'NSRangeException',原因 : '*** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds [0 .. 2]'

我尝试在UIPageView中显示三张图片,但每次滑动到第三张图片时,我都会收到此错误:'NSRangeException',原因:'***-[__NSArrayIobjectAtIndex:]:索引3超出范围[0..2]'我已经检查了关于同一问题的其他问题,但无法弄清楚我的问题出在哪里。这是输出的其余部分:***Firstthrowcallstack:(0CoreFoundation0x000000010a410c65__exceptionPreprocess+1651libobjc.A.dylib0x000000010a0a9bb7objc_exception_throw+452C

Swift - 带三角形的模糊圆圈 - 模糊效果始终在顶部

我正在尝试创建一个简单的圆形按钮并在该按钮内放置一个三角形,它实际上是一个播放按钮。问题是,当我将BlurEffect添加到按钮时,它始终位于顶部并且会隐藏三角形。有没有办法在模糊效果上方添加三角形?importUIKit@IBDesignableclassCirclePlayButton:UIButton{letblur=UIBlurEffect(style:.Light)overridefuncdrawRect(rect:CGRect){letblurEffect=UIVisualEffectView(effect:blur)blurEffect.alpha=0.9//self.a

ios - 在不使用 CAShapeLayer 的情况下冲破 UIBezierPath 的笔划并为此笔划设置动画

UIBezierPath只有在UIView的drawRect()方法中使用时才会变成虚线,如下所示:overridefuncdraw(_rect:CGRect){letpath=UIBezierPath()letp0=CGPoint(x:self.bounds.minX,y:self.bounds.midY)path.move(to:p0)letp1=CGPoint(x:self.bounds.maxX,y:self.bounds.midY)path.addLine(to:p1)letdashes:[CGFloat]=[0.0,16.0]path.setLineDash(dashes,

ios - 制作自定义形状 imageview ios swift 4.2

我是ios的新手。我正在尝试将ImageView的底部边框(不是整个底部的左侧或右侧)制作成曲线。任何人都可以指导我如何去做。Hereistheimageoftheborderiwanttoacheive: 最佳答案 你可以这样做:funccurvedShapeFor(view:UIImageView,curvedPercent:CGFloat)->UIBezierPath{letpath=UIBezierPath()path.move(to:CGPoint(x:0,y:0))path.addLine(to:CGPoint(x:vi

iOS - iPad 的 viewWillTransition 中错误的 UIScreen 边界

我必须检查我的设备在iOS8+中是否改变了方向。我的做法是:overridefuncviewWillTransition(tosize:CGSize,withcoordinator:UIViewControllerTransitionCoordinator){super.viewWillTransition(to:size,with:coordinator)letisLand=UIScreen.main.bounds.width>UIScreen.main.bounds.heightcoordinator.animate(alongsideTransition:nil){_inleti

swift - 键路径为 "bounds"的 CABasicAnimation 不工作

我有以下代码使用CABasicAnimation对CALayer的边界属性进行动画处理。但是代码似乎不起作用。letfromValue=textLabel.layer.boundslettoValue=CGRectMake(textLabel.layer.bounds.origin.x,textLabel.layer.bounds.origin.y,textLabel.layer.bounds.width,textLabel.layer.bounds.height+50)letpositionAnimation=CABasicAnimation(keyPath:"bounds")pos

ios - view.bounds.size.height -vs- view.bounds.height——有什么区别吗?

我注意到在使用(Swift4.0)的IOSX代码中,我至少可以通过以下两种方式请求View的高度V:V.bounds.size.height和...V.bounds.height这两者之间有什么实际区别吗?我做了选项单击的事情(它给出了不同的定义,但没有解释任何实际差异或原因)......和​​stackoverflow......但是在stackoverflow上,所有结果都在讨论bounds和frame之间的区别...这不是我要问的。 最佳答案 V.bounds.height只是一个GET属性。您不能为此属性设置值。示例:sel

ios - UIBezierPath下绘制渐变

我画了一条曲线。我想从View一直到线设置渐变(这样渐变会随着线弯曲。)编辑:这是下面代码生成的照片:我知道如何画线,我知道如何添加规则的渐变,但只是不会将两者结合起来。这是我的代码:overridefuncdrawRect(rect:CGRect){//drawthecurvedline,thiscodeworksjustfine.letpath1=UIBezierPath()path1.lineWidth=1.1UIColor.greenColor().setStroke()path1.moveToPoint(CGPoint(x:0,y:bounds.height/2))path1

ios - 异常的 UITableView 崩溃 -[__NSArrayM objectAtIndex :]: index 0 beyond bounds for empty array

我进行了大量搜索,但没有找到似乎可以解决我遇到的问题的答案。我有一个UITableViewController。在viewDidLoad方法中,我从数据库加载对象,然后调用reloadData。现在一般来说这工作正常。但是,现在我正在实现排序,它会持续存在,以便在下一次应用程序启动时使用相同的排序算法。请注意,在所有情况下,支持该部分的数组的大小在排序后都是相同的。如果我使用默认排序方法,即使它运行相同的排序>调用委托(delegate)>reloadTable代码路径,我也不会崩溃。但是,如果我使用使用相同代码路径的替代排序方法,我会看到TableView要求行数,并获得正确的数字,

ios - 截图在模拟器中有效,但在真实设备上失败

我有以下代码截取游戏屏幕截图,然后在点击“分享”按钮时分享它。它在模拟器上运行良好并返回正确的图像。但是,在我的真实设备上,它返回一个白色图像。每次。代码如下:overridefunctouchesBegan(_touches:Set,withevent:UIEvent?){letTouch:UITouch!=touches.firstletTouchLocation=Touch.location(in:self)ifletbody=self.physicsWorld.body(at:TouchLocation){ifbody.node!.name=="shareButton"{let