小编Jar*_*edH的帖子

Xcode Playground 无法启动

我无法运行任何 Xcode Swift Playground 项目而不收到错误:

启动进程失败。无法附加到存根以进行游乐场执行:错误:附加失败((os/kern)无效参数)

有谁知道如何解决这个问题?

xcode swift apple-m1

54
推荐指数
2
解决办法
2万
查看次数

Xcode 控制台“po”错误:表达式解析失败

我的 Xcodepo突然无法执行任何操作。

例如:

po param

error: expression failed to parse:
error: Couldn't realize type of self.
Run Code Online (Sandbox Code Playgroud)

每次我使用po在控制台中打印某些内容时,它都会显示上述错误。这件事从一个月前开始发生。

xcode ios swift

11
推荐指数
2
解决办法
9348
查看次数

NavigationView / NavigationLink 自定义过渡方向

我试图NavigationLink从屏幕底部加载视图,而不是从右侧转换,但“明显”的方法(使用 a .transition(.move(edge: .bottom)))似乎没有任何效果。

下面是里面的NavigationView

List {
    ForEach(self.message, id: \.self) { message in
        HStack(alignment: .center) {
            MessageListCell(....)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

MessageListCell

    var body: some View {
        HStack {
            VStack(alignment: .leading, spacing: 0) {
                Text(person.firstName).lineLimit(1)
                    .foregroundColor(.main)
            }
            Spacer()
            NavigationLink(destination: MessageDetail(otherPerson: otherPerson,
                                                   subject: subject,
                                                   profileHandler: { ProfileReducer($0) })
                .transition(.move(edge: .bottom)),
                           tag: 1, selection: $action) {
                NextButton("Proceed")
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

NextButton从屏幕右侧而不是底部点击一致的过渡。我已经尝试过上述方法的变体,但我开始认为这transition可能不是正确的方法。

swiftui swiftui-navigationlink

7
推荐指数
0
解决办法
4914
查看次数

ARKit - SCNNode连续移动

我正在尝试创建一个用户堆叠不同几何形状的应用程序.在加载到ARSCNView内的.scn文件中,我插入一个静态平面,然后在用户的每次点击时,应用程序插入一个动态SCNNode.

第一个节点插入平面上方几英寸处,以复制掉落的物体.然后,每个其他节点都被丢弃在另一个节点之上.

这是该应用程序的主要思想; 在添加3个或4个节点后出现问题,它们看起来互相滑动,几乎抖动,整个结构崩溃.

这是我插入的节点:

let dimension: CGFloat = 0.075
let cube = SCNBox(width: dimension, height: dimension, length: dimension, chamferRadius: 0.0)
let node = SCNNode(geometry: cube)

node.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.dynamic, shape: nil)
node.physicsBody?.mass = 2.0

node.physicsBody?.friction = 1.0
node.physicsBody?.restitution = 0.01

node.physicsBody?.damping = 0.0
node.physicsBody?.angularDamping = 0.0

node.physicsBody?.rollingFriction = 1.0

node.physicsBody?.allowsResting = true

let insertionYOffset = 0.3
node.position = SCNVector3(hitResult.worldCoordinates.x, hitResult.worldCoordinates.y + Float(insertionYOffset), hitResult.worldCoordinates.z)
Run Code Online (Sandbox Code Playgroud)

我试图使用这些值,这些是最好的,但它们不足以创建稳定的块结构.

作为一项要求,我需要保持块的动态,它们需要受到重力,风等的影响.

ios scenekit swift arkit

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

为Palindrome创建递归方法

我试图在Java中使用递归创建一个Palindrome程序,但我被卡住了,这是我到目前为止:

 public static void main (String[] args){
 System.out.println(isPalindrome("noon"));
 System.out.println(isPalindrome("Madam I'm Adam"));
 System.out.println(isPalindrome("A man, a plan, a canal, Panama"));
 System.out.println(isPalindrome("A Toyota"));
 System.out.println(isPalindrome("Not a Palindrome"));
 System.out.println(isPalindrome("asdfghfdsa"));
}

public static boolean isPalindrome(String in){
 if(in.equals(" ") || in.length() == 1 ) return true;
 in= in.toUpperCase();
 if(Character.isLetter(in.charAt(0))
}

public static boolean isPalindromeHelper(String in){
 if(in.equals("") || in.length()==1){
  return true;
  }
 }
}
Run Code Online (Sandbox Code Playgroud)

谁能为我的问题提供解决方案?

java recursion palindrome

5
推荐指数
2
解决办法
11万
查看次数

Objective-C块语法

Obj-C块是我刚刚第一次使用的东西.我试图理解以下块语法:

在头文件中:

@property (nonatomic, copy) void (^completionBlock)(id obj, NSError *err);
Run Code Online (Sandbox Code Playgroud)

在主文件中:

-(void)something{

id rootObject = nil;

// do something so rootObject is hopefully not nil

    if([self completionBlock])
        [self completionBlock](rootObject, nil); // What is this syntax referred to as?
}
Run Code Online (Sandbox Code Playgroud)

我很感激你的帮助!

syntax objective-c objective-c-blocks

5
推荐指数
2
解决办法
629
查看次数

如何在每次重置标题时阻止UIButton突出显示/闪烁?

我使用UIButton作为标签在其标题中显示一些数字.每次调用该函数以重置此按钮的标题时,它都会闪烁.它不会影响功能但会损害用户体验.我想知道是否有办法阻止UIButton突然出现这种突出行为?

提前致谢!

编辑:以下是我只是调用委托方法updateDigits刷新按钮标题的代码.

class ViewController: UIViewController, UIPopoverPresentationControllerDelegate, DigitsEntryViewDelegate {

    @IBOutlet weak var tipField1: UIButton!
    @IBOutlet weak var tipField2: UIButton!

    var buttonsArray = [UIButton]()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        self.tipField1.tag = 0
        self.tipField2.tag = 1

        self.tipField1.addTarget(self, action: "inputFieldClicked:", forControlEvents: UIControlEvents.TouchUpInside)
        self.tipField2.addTarget(self, action: "inputFieldClicked:", forControlEvents: UIControlEvents.TouchUpInside)

        self.buttonsArray.append(self.tipField1)
        self.buttonsArray.append(self.tipField2)
    }


    func inputFieldClicked(sender: UIButton) {
        let anchor: UIView = sender

        let viewControllerForPopover = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("DigitEnter") as! DigitsEntryViewController …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch uibutton ios swift

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