小编Ter*_*min的帖子

CGRectDivide在swift 3中已弃用

正如swift 3所说的那样CGRectDivide,已被弃用并且更换了divided(atDistance: CGFloat, from fromEdge: CGRectEdge) -> (slice: CGRect, remainder: CGRect).

据我所知CGRectDivide,默认情况下将源矩形划分为两个组件矩形.问题是做什么以及用什么来执行CGRectDivide使用swift 3做的相同操作?

更新1:swift 2功能如下所示:

fileprivate func isLeftPointContainedWithinBezelRect(_ point: CGPoint) -> Bool{
    if let bezelWidth = SlideMenuOptions.leftBezelWidth {
        var leftBezelRect: CGRect = CGRect.zero
        var tempRect: CGRect = CGRect.zero

        CGRectDivide(view.bounds, &leftBezelRect, &tempRect, bezelWidth, CGRectEdge.minXEdge)

        print("------> slidee1")

        return leftBezelRect.contains(point)
    } else {
        return true
    }
}
Run Code Online (Sandbox Code Playgroud)

ios cgrect swift swift3

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

使用C#将big endian的float值转换为little endian

是否有可能将浮动从大端转换为小端?我有一个来自大端平台的值,我通过UDP发送到Windows进程(小端).这个值是一个浮点数,但是当我尝试BitConverter.ToSingle时,我总是得到5.832204E-42,但它应该是36.000.

我究竟做错了什么?

这是一段剪切的代码:

// Receive thread
private void ReceiveData()
{
    int count = 0;

    IPEndPoint remoteIP = new IPEndPoint(IPAddress.Parse("10.0.2.213"), port);
    client = new UdpClient(remoteIP);
    while (true)
    {
        try
        {
            IPEndPoint anyIP = new IPEndPoint(IPAddress.Any, 0);
            byte[] data = client.Receive(ref anyIP);

            float x = BitConverter.ToSingle(data, 0);
            float y = BitConverter.ToSingle(data, 4);
            float z = BitConverter.ToSingle(data, 8);
            float alpha = BitConverter.ToSingle (data, 12);
            float theta = BitConverter.ToSingle (data, 16);
            float phi = BitConverter.ToSingle (data, 20);

            print(">> " + …
Run Code Online (Sandbox Code Playgroud)

c# arrays floating-point endianness

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

标签 统计

arrays ×1

c# ×1

cgrect ×1

endianness ×1

floating-point ×1

ios ×1

swift ×1

swift3 ×1