小编pin*_*dax的帖子

什么是Device.BeginInvokeOnMainThread?

我想有人向我解释什么是Device.BeginInvokeOnMainThread?它的用途是什么?使用案例的例子.

谢谢.

xamarin xamarin.forms

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

Android模拟器未运行 - Visual Studio 2017

我最近安装了VS 2017.试图运行一个空白的Android App Project.安装了所有必需的工具但是当我尝试从Visual Studio中启动模拟器时,我得到了这个:

在此输入图像描述

任何帮助将不胜感激.

c# android emulation xamarin.android xamarin

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

Xamarin - 如何使用 xamarin mac 获取屏幕截图并将其保存在磁盘上?

我正在尝试在 Mac 上使用 Xamarin 和 C# 抓取屏幕截图并将其保存在磁盘上。我写了下面的代码:

public static void TakeScreenshotAndSaveToDisk(string path)
    {
        var fullScreenBounds = NSScreen.MainScreen.Frame;
        IntPtr ptr = CGWindowListCreateImage(fullScreenBounds, CGWindowListOption.OnScreenAboveWindow, 0, CGWindowImageOption.Default);
        var cgImage = new CGImage(ptr);
        var fileURL = new NSUrl(path, false);
        var imageDestination = CGImageDestination.Create(new CGDataConsumer(fileURL), UTType.PNG, 1);
        imageDestination.AddImage(cgImage);
        imageDestination.Close();
        imageDestination.Dispose();
        fileURL.Dispose();
        cgImage.Dispose();
    }
Run Code Online (Sandbox Code Playgroud)

该方法执行并且文件出现在正确的位置。如果我尝试打开它,它将显示空白。如果我单击文件上的“获取信息”,它将不会显示预览。关闭应用程序后,可以打开图像并“获取信息”显示预览。

我在这里做错了什么?在我看来,即使我对对象调用 Dispose() ,资源也没有被释放。

谢谢。

c# macos screenshot xamarin xamarin.mac

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

添加启动屏幕故事板后 Xamarin iOS 布局发生变化

我继承了一个旧的 xamarin 代码库。它以这种带有顶部和底部黑条的奇怪窗口形式启动(如下图所示)。它还使用启动图像。一旦我开始使用启动故事板,应用程序就会变成全屏(没有顶部/底部黑条),结果,所有的布局都搞砸了。

有谁知道如何在不移除黑条的情况下拥有启动故事板?

非全屏布局

xamarin.ios ios autolayout xamarin

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

在 Xamarin Forms 中添加按钮的最佳方法是什么?

所以我是 Xamarin Forms 的新手,我发现了两种添加按钮的方法:

1.在.xaml文件中声明按钮

 <!--  <Button Text="Click Me!"
      Clicked="OnButtonClicked" VerticalOptions="CenterAndExpand" />-->
Run Code Online (Sandbox Code Playgroud)

和 .xaml.cs 文件

 public void OnButtonClicked(object sender, EventArgs args)
     {
         count++;

         label.Text =
             String.Format("{0} click{1}!", count, count == 1 ? "" : "s");
Run Code Online (Sandbox Code Playgroud)
  1. 仅在 .xaml.cs 文件中声明按钮

    using System;
    using Xamarin.Forms;
    
    namespace FormsGallery
    {
        class ButtonDemoPage : ContentPage
        {
            Label label;
            int clickTotal = 0;
    
            public ButtonDemoPage()
            {
                Label header = new Label
                {
                    Text = "Button",
                    Font = Font.BoldSystemFontOfSize(50),
                    HorizontalOptions = LayoutOptions.Center
                };
    
                Button button = new Button …
    Run Code Online (Sandbox Code Playgroud)

c# xaml xamarin xamarin.forms visual-studio-2017

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

如何在 iOS 中的同一个 UICollectionView 中加载图像和视频

请参考这张图片

我正在尝试创建一个集合视图,它可以根据时间戳显示相机胶卷中的所有图像和视频。

我只能加载图像或视频,不能同时加载两者。

我试过下面的代码

        var photos: PHFetchResult<PHAsset>! // user photos array in collectionView for disaplying video thumnail 
        func getAssetFromPhoto() {
            let options = PHFetchOptions()
            options.sortDescriptors = [ NSSortDescriptor(key: "creationDate", ascending: true) ]
            options.predicate = NSPredicate(format: "mediaType = %d", PHAssetMediaType.video.rawValue)
            photos = PHAsset.fetchAssets(with: options)
            print(photos)
            photoCollectionView.reloadData() // reload your collectionView
        }
Run Code Online (Sandbox Code Playgroud)

正如您在上面的代码片段中看到的,在定义选项时我们只能要求视频采集或图像采集。

我怎样才能将它们两者结合起来。请注意:我愿意接受任何类型的开发建议,作为一种解决方法,我将 PHFetchResult 合并到一个集合中并填充我的集合视图。

这是唯一的方法吗?或者 Apple 是否为相同的 .

avfoundation ios swift photokit

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