小编Dum*_*pen的帖子

使用"自动布局"将UITableView的高度设置为其内容的高度

我有一个View,里面有两个标签和一个Table View.我希望标签1始终位于我的表视图上方并标记为2,位于表格视图下方.问题是表视图需要自动调整高度或增加的含义.

现在我有一个约束说,表视图的高度总是等于85,并且a @IBOutlet到高度约束,我可以改变常量.

我猜我需要将常数更改为所有单元格的高度,但我不确定如何.

菜单限制

uitableview ios swift

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

使用List和Stack实现深度优先搜索到C#

我想创建一个深度优先搜索,我有点成功.

这是我到目前为止的代码(除了我的构造函数,请注意Vertex和Edge类只包含属性,这里没有重要的内容):

private Stack<Vertex> workerStack = new Stack<Vertex>();
private List<Vertex> vertices = new List<Vertex>();
private List<Edge> edges = new List<Edge>();

private int numberOfVertices;
private int numberOfClosedVertices;
private int visitNumber = 1;

private void StartSearch()
{
    // Make sure to visit all vertices
    while (numberOfClosedVertices < numberOfVertices && workerStack.Count > 0)
    {
        // Get top element in stack and mark it as visited
        Vertex workingVertex = workerStack.Pop();
        workingVertex.State = State.Visited;

        workingVertex.VisitNumber = visitNumber;
        visitNumber++;

        numberOfClosedVertices++;

        // Get all edges connected to …
Run Code Online (Sandbox Code Playgroud)

c# search edges depth vertex

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

如何从jQuery ajax调用获得响应时间?

所以我正在开发一种工具,可以显示对页面的请求.

我是通过使用jQuery Ajax(http://api.jquery.com/jQuery.ajax/)来做到这一点的,我想弄清楚获得响应时间的最佳方法.

我找到了一个线程(http://forum.jquery.com/topic/jquery-get-time-of-ajax-post),它描述了在JavaScript中使用"Date",但这个方法真的可靠吗?

我的代码示例如下所示

$.ajax({
    type: "POST",
    url: "some.php",
}).done(function () {
    // Here I want to get the how long it took to load some.php and use it further
});
Run Code Online (Sandbox Code Playgroud)

ajax time jquery response request

17
推荐指数
1
解决办法
3万
查看次数

使用UDP接收时安全地结束线程

我正在创建一个运行UDP客户端接收消息的线程,在收到消息后我要关闭UDP客户端然后结束线程,但我不知道如何结束线程,因为"接收"总是运行直到它得到了答案.

到目前为止这是我的代码:

private void RecieveChallenge()
{
    UdpClient client = new UdpClient(26000);
    IPEndPoint remoteIp = new IPEndPoint(IPAddress.Any, 0);

    Byte[] receivedBytes = client.Receive(ref remoteIp);
    string ipAddress = Encoding.ASCII.GetString(receivedBytes);
}
Run Code Online (Sandbox Code Playgroud)

重要的一行是client.Receive(ref remoteIp);

这是我开始我的线程的方式:

Thread recieveChallengeThread = new Thread(new ThreadStart(RecieveChallenge));
recieveDataThread.Start();
Run Code Online (Sandbox Code Playgroud)

c# multithreading udp

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

jQuery UI Datepicker - 禁用当前日期但不是高亮显示

我有以下代码通过将minDate设置为当前日期+ 1来禁用当前日期:

    var today = new Date();
    var tomorrow = new Date();
    tomorrow.setDate(today.getDate() + 1);

        $("#minDate").datepicker({
            showOn: "none",
            minDate: tomorrow,
            dateFormat: "DD dd-mm-yy",
            onSelect: function(dateText) {
                minDateChange;
            },
            inputOffsetX: 5,
        });
Run Code Online (Sandbox Code Playgroud)

禁用当前日期的Datepicker

问题是我想要禁用当前日期,但仍然在日历中突出显示(日期周围的蓝色边框).

是否有使用datepicker执行此操作的本机方法,或者我是否必须自己创建突出显示脚本?

javascript jquery user-interface datepicker

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

将一个int列表移动到列表的前面

我有一个Int64列表(列表A)需要移动到另一个列表(Int64)(列表B)的前面.

列表B将始终包含列表A中的数字.

所以说列表A有以下数字:

1, 4, 5
Run Code Online (Sandbox Code Playgroud)

列表B可能看起来像这样:

1, 9, 5, 2, 10, 15, 4
Run Code Online (Sandbox Code Playgroud)

最终结果应如下所示:

1, 4, 5, 9, 2, 10, 15
Run Code Online (Sandbox Code Playgroud)

将数字从第一个列表移动到第二个列表前面的最简单方法是什么?

我想从列表B中删除所有列表A号码,然后再将它们添加到前面,但我似乎无法理解编程本身.

c# linq sorting list

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

在DataTemplate DataType中使用命名空间

我正在尝试使用ListBox和ItemsSource属性显示来自YouTube的视频列表.

我现在的工作(下图),但现在我需要格式化我的数据.

<ListBox Name="lbVideos" ItemsSource="{Binding Source={StaticResource listOfVideos}}"/>
Run Code Online (Sandbox Code Playgroud)

为此,我使用的是DataTemplate,但问题是该类型是Google.YouTube.Video.

<Application x:Class="YouTube_Notifier.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Startup="AppStartup"
    xmlns:src="clr-namespace:YouTube_Notifier" 
    xmlns:System="clr-namespace:System;assembly=mscorlib">
    <Application.Resources>
        <DataTemplate DataType="{x:Type src:Google:YouTube:Video}">
        </DataTemplate>
    </Application.Resources>
</Application>
Run Code Online (Sandbox Code Playgroud)

上面的代码导致我收到错误"Type'src:找不到Google.YouTube.Video".

我要问的是如何在DataTemplate中使用命名空间?

data-binding wpf xaml namespaces datatemplate

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

将逗号分隔的字符串转换为GetFiles SearchPattern

我有以下代码:

private string[] FindExistingDocuments()
{
    string supportedImageFormats = "jpg,pdf,doc,docx,xlsx";

    DirectoryInfo documentPath = new DirectoryInfo("...");

    string supportedFileTypes = String.Join(",*.", supportedImageFormats.Split(','));
    string[] files = Directory.GetFiles(documentPath.FullName, supportedFileTypes, SearchOption.AllDirectories);

    return files;
}
Run Code Online (Sandbox Code Playgroud)

其中一个用作搜索特定文件类型列表的方法,但当前代码的问题是String.Join不将分隔符放在第一个项目(这是有意义的).

所以我的supportedFileTypes结果是:

jpg,*.pdf,*.doc,*.docx,*.xlsx
Run Code Online (Sandbox Code Playgroud)

但我希望它是:

*.jpg,*.pdf,*.doc,*.docx,*.xlsx
Run Code Online (Sandbox Code Playgroud)

我可以以一种非常干净的方式做到这一点吗?

注意:我无法改变内容 supportedImageFormats

c# string split join getfiles

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

将div放在居中图像的顶部

我有一个看起来像这样的标记:

<div style="width: 150px; height: 250px;">
    <img src="Image1.jpg" />

    <div class="YellowExclaimIcon iconsBlack"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

我要实现的目标如下:

结果

这意味着图像应始终位于父div的中心(水平和垂直),警告图标应位于图像顶部,右边和底部的边距为5。

另外要注意的是,图像的宽度和高度并不总是相同的,但是警告图标的位置应始终位于正确的位置。

YellowExclaimIcon类包含背景图像,但是可以根据需要更改为图像。要考虑的是图像还具有最大宽度和最大高度。

我尝试了此线程CSS帮助中的答案-图像上的div,但无法使其与居中一起使用。

html css image center

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

document.queryCommandValue在Firefox中返回(空字符串)

我想读一下contenteditable元素中的某个文本是否为粗体.在Chrome中document.queryCommandValue("bold")返回"true"/"false"一个字符串,IE返回true/false的布尔,但Firefox返回(empty string)在开发者控制台.

我做了一个小提琴作为例子:http: //jsfiddle.net/nTQd2/

如果您在div中写入som文本,请将其标记,然后点击"Bold",该范围应显示"true"/"false"true/false.我真的不在乎它是作为字符串还是布尔值,因为我可以在以后转换它.

javascript firefox html5 contenteditable

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

按属性分组列出<人员>并获取分组的次数

假设我有一个名为Person的类:

public class Person
{
    public int Age { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

一份人员名单:

Person { Age = 20, FirstName = "John", LastName = "Joe" }
Person { Age = 20, FirstName = "John", LastName = "Joe" }
Person { Age = 10, FirstName = "James", LastName = "Dokes" }
Run Code Online (Sandbox Code Playgroud)

我想要的是(新的或旧的具有新属性)列表按年龄,名字和姓氏对人进行分组我还想知道该对象被分组的次数.

所以上面的结果将是:

Person { Age = 20, FirstName = "John", LastName = "Joe", Count = 2 …
Run Code Online (Sandbox Code Playgroud)

c# properties list linq-group

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