小编Jas*_*ter的帖子

自从更新到 xcode 12 以来,我无法在 UITableViewCell 中放置任何 UIControl

我有一个使用 tableview 的搜索表单。今天更新 Xcode 12 后,UISwitch、UITextField、UISlider 在嵌套在 UITableViewCell 中时不再工作。是否有一个属性发生了变化,我需要设置它才能再次工作?

为了确保这不仅仅是我的项目,我创建了一个新项目并在其中放置了一个 UITextField,但它也不起作用。

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = UITableViewCell()
    
    let textField = UITextField(frame: CGRect(x: 5, y: 5, width: 400.0, height: 25.0))
    textField.delegate = self
    textField.backgroundColor = .blue
    cell.addSubview(textField)

    return cell
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    print("this will get called even when selecting the UITextField")
}

func textFieldDidBeginEditing(_ textField: UITextField) {
    print("this is never called")
}
Run Code Online (Sandbox Code Playgroud)

uitableview uicontrol xcode12

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

剥离Objective-C中的所有Exif数据

如何使用objective-c去除UIImage中的所有exif数据?我已经能够使用以下内容获取exif数据:

NSData* pngData =  UIImagePNGRepresentation(image);
CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)pngData, NULL);

NSDictionary* dic   =   nil;
if ( NULL == imageSource )
{
    #ifdef _DEBUG
    CGImageSourceStatus status = CGImageSourceGetStatus ( source );
    NSLog ( @"Error: file name : %@ - Status: %d", file, status );
    #endif
}
else
{
    CFDictionaryRef propertyRef = CGImageSourceCopyPropertiesAtIndex ( imageSource, 0, NULL );
    CGImageMetadataRef metadataRef = CGImageSourceCopyMetadataAtIndex ( imageSource, 0, NULL );
    // CFDictionaryRef metadataRef = CFDictionaryGetValue(imageProperties, kCGImagePropertyExifDictionary);
    if (metadataRef) {
        NSDictionary* immutableMetadata = (NSDictionary *)metadataRef;
        if …
Run Code Online (Sandbox Code Playgroud)

exif objective-c uiimage

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

以编程方式添加时,应用程序在 NSLayoutConstraint 上崩溃

我收到以下错误:

添加到视图时,约束的项目必须是该视图(或视图本身)的后代。如果在组装视图层次结构之前需要解决约束,这将会崩溃。中断 -[UIView(UIConstraintBasedLayout)

基本上我想要一个 200h x 200w 的蓝色视图,位于屏幕中间。

UIViewController.swift

override func loadView() {
    super.loadView()
    self.view = View()
}
Run Code Online (Sandbox Code Playgroud)

同时在 View.swift 中

class View: UIView {
var blueView : UIView?

convenience init() {
    // also tried  UIScreen.mainScreen().bounds
    self.init(frame:CGRectZero)
    self.backgroundColor = UIColor.redColor()
    self.setupView()
}

required init?(coder aDecoder: NSCoder) {
    fatalError("init:coder")
}

override init(frame: CGRect) {
    super.init(frame: frame)
}

func setupView() {
    self.blueView = UIView()
    self.blueView?.backgroundColor = UIColor.blueColor()
    self.blueView?.translatesAutoresizingMaskIntoConstraints = false
    // self.translatesAutoresizingMaskIntoConstraints = false
    self.addSubview(self.blueView!)

    let centerXConstraint = NSLayoutConstraint(
        // object that …
Run Code Online (Sandbox Code Playgroud)

ios nslayoutconstraint swift

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