小编Dmi*_*oly的帖子

在后台接收UIPasteboard(generalPasteboard)通知

有没有办法做到这一点?我UIPasteboardChangedNotification在发布时注册了我的对象,但是当它发送到后台并打开(例如)Safari并复制一些文本时,我的处理程序永远不会被调用.(我现在只使用模拟器).

我用过两个:

[[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(pasteboardNotificationReceived:) 
    name:UIPasteboardChangedNotification 
    object:[UIPasteboard generalPasteboard]];
Run Code Online (Sandbox Code Playgroud)

和:

[[NSNotificationCenter defaultCenter] addObserver:self 
    selector:@selector(pasteboardNotificationReceived:) 
    name:UIPasteboardChangedNotification 
    object:nil ];
Run Code Online (Sandbox Code Playgroud)

注册我的处理程序.

cocoa-touch uipasteboard generalpasteboard

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

通过反射在c#中创建类的实例

考虑以下代码:

class Program
{
    static void Main(string[] args)
    {
        var instance = Activator.CreateInstance<Person>();//No parameterless constructor defined for this object.

    }
}

public class Person
{
    public Person(string name = "Shahrooz") { }
}
Run Code Online (Sandbox Code Playgroud)

使用此代码时:Activator.CreateInstance<Person>();我收到此错误:

没有为此对象定义的无参数构造函数.

请注意,我的构造函数有默认参数:string name ="Shahrooz"

为什么我们不能从具有构造函数的类创建实例,尽管构造函数具有默认值参数?

c#

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

我可以在 Linux 中编译 .net Core 3 WPF 应用程序吗?

.net Core 3.0 中添加了 WPF 支持

我可以在 Linux 或基于 Linux 的 docker 容器中编译 wpf 应用程序吗?

c# wpf .net-core-3.0

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