标签: uikit

UITextField 中的 borderRect、editingRect、placeholderRect、textRect 是什么?

从之前发布的答案中,我了解到这editingRect是在编辑文本时显示的矩形,也是textRect在未编辑文本时显示的矩形。但我不知道placeholderRect和确切地borderRect显示在 UITextField 控件中的位置。我认为它borderRect与 UITextField 的框架矩形相同,因为其中有“border”一词,但在执行此操作之后:

override func borderRect(forBounds bounds: CGRect) -> CGRect {
    let rect = bounds
    rect.size.height = 150 //the height of my UITextField currently is 100
    return rect
}
Run Code Online (Sandbox Code Playgroud)

我意识到事实并非如此。那么placeholderRect和是什么borderRect,它们位于 UITextField 中的什么位置?

uitextfield uikit ios swift

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

IOS/swift currentTitle 返回 nil

当我使用 时titlelabel.text,它可以正常打印我的结果,但是当我使用 时currenttitle,它返回 nil。我检查了文件。currenttitletitlelabel.text都是快速访问方法,但为什么我得到不同的结果

@IBAction func numBtnPress(_ sender: UIButton) {
  print(sender.titleLabel?.text)
  print(sender.currentTitle)
}
Run Code Online (Sandbox Code Playgroud)

问题截图如下

在此输入图像描述

uikit ios swift

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

AVSampleBufferDisplayLayer 中的画中画未加载

我正在尝试为我的 iOS 应用程序支持画中画,并且我需要显示视图的内容,而不是视频。因此,我尝试使用库来记录视图并以AVSampleBufferDisplayLayer. 它有效,视图的内容显示在缓冲区显示层中,但是当我尝试使用 PIP 时,只显示加载指示器。这是我的代码:

import UIKit
import AVKit

class View: UIView {
    
    override class var layerClass: AnyClass {
        AVSampleBufferDisplayLayer.self
    }
}

class ViewController: UIViewController, AVPictureInPictureSampleBufferPlaybackDelegate {
    
    func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, setPlaying playing: Bool) {
        
    }
    
    func pictureInPictureControllerTimeRangeForPlayback(_ pictureInPictureController: AVPictureInPictureController) -> CMTimeRange {
        .init(start: .zero, duration: self.buffers.first?.duration ?? .indefinite)
    }
    
    func pictureInPictureControllerIsPlaybackPaused(_ pictureInPictureController: AVPictureInPictureController) -> Bool {
        false
    }
    
    func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, didTransitionToRenderSize newRenderSize: CMVideoDimensions) {
        
    }
    
    func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, skipByInterval skipInterval: CMTime, completion completionHandler: …
Run Code Online (Sandbox Code Playgroud)

uikit ios swift avkit

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

说Getter是实例变量的所有者是否有效?或谁拥有它?

其实我会说:是的,Getter是主人.因此,任何调用Getter的人都不负责释放内存.或者更确切地说,对象本身是所有者,但Getter充当实例变量的传递机制给其他人.这是对的,还是我弄错了?

cocoa cocoa-touch objective-c uikit

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

输入xcode时出错

当我没有输入任何代码时,我不断收到错误:

"无法为UIKit加载底层模块"

我可以清理和构建,它仍然运行,但为什么出现错误,我该如何摆脱它?

xcode uikit xcode6

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

动画集合视图单元格

如何为集合视图单元设置动画,例如iOS中左右门的关闭或滑动。像这样:在此处输入图片说明

uikit uiviewanimation uicollectionview uicollectionviewcell swift

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

Swift 2 秒后如何隐藏 UILabel?

当我点击按钮 UILabel 出现并立即再次消失。我需要它在几秒钟后消失。这是我的第一个应用程序,我无法解决这个问题。谢谢!

func done() {
    if sauserImageView.isHidden == false && cupImageView.isHidden == false && spoonImageView.isHidden == false {
        winningLabel.isHidden = false

    }
}
Run Code Online (Sandbox Code Playgroud)

uikit uilabel swift

-2
推荐指数
1
解决办法
1802
查看次数

iOS - 如何从中心旋转imageView 360度

我想在我的iOS应用程序中旋转我的imageView 360度

(当我的标签文字是"你好")

请帮我

if ([myLabel.text isEqualToString:@"hello"] == YES)
{
    //here i want the imageView to rotate

}
Run Code Online (Sandbox Code Playgroud)

animation uikit uiimageview ios

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

UITabel在UITableViewCell中的位置在第一次尝试时失败

刚刚开始使用iOS开发,我希望我能在这里获得正确的详细信息......

我有一个UILabel,加载在通过.xib创建的表格单元格中.实际上是几个标签,其中一个标签长度不同(因此包装高度不同). heightForRowAtIndexPath被正确覆盖的等等,并且正确计算了两个标签所需的高度并分配给每个标签.frame

一旦设置了两个尺寸,我设置较小(固定长度,总是一行高)标签的frame.origin.y以匹配较大标签的尺寸.这可以看作是可以看到逐步通过cellForRowAtIndexPath但是在新创建的单元的初始显示上,原点似乎在容器中不是非常垂直居中,而不是顶部向上.

单击"穿过"单元格到另一个视图,然后返回到(现在重用,并且可能已经是正确大小的容器),位置设置为之前,它出现在我预期的位置.

看起来像容器后被调整cellForRowAtIndexPath收益,并在那里的某处新的位置找到了我们的标签; 这可以解释为什么以后重复使用单元格可以解决问题.

我已经尝试了内外模式和基线设置,拉伸设置等各种明显合理的组合.无法解释和/或解决方法.

更新:

关于在自定义UITableViewCell问题中更改自定义UIButton位置的建议解决了这个问题.解决方案是子类化UITableViewCell和覆盖layoutSubviews,从而有机会在TableView完成其正常定位后重新定位子元素.一旦这个人在这里做出回应,或者赏金到期,我将用代码回答我自己.

uitableview uikit ios

-7
推荐指数
1
解决办法
2344
查看次数