小编Dar*_*ius的帖子

OpenGL - 为什么我的对象是透明的?

我正在尝试制作具有原始形状的摩托车。出于某种原因,我制作的形状是透明的。我没有在任何地方指定任何 alpha;这是我的代码:

#include <GL/glut.h>
#include <math.h>

GLUquadricObj *quadratic;
static int isWire = 0; // Is wireframe?
static int distance = 10;
static float angleH = 0;
static float angleV = 0;

static float R = 2.0; // Radius of hemisphere.
static int p = 4; // Number of longitudinal slices.
static int q = 6; // Number of latitudinal slices.

#define PI 3.14159265358979324

static unsigned int pipe, seat, cover, wheel, wheelCenter, cycles; // parts of the motorcycle to make as …
Run Code Online (Sandbox Code Playgroud)

opengl transparency

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

使用C#Reactive Extensions在特定时间调用函数

是否可以使用Reactive Extensions在特定时间调用函数?

例如,如果我想在每天早上9点和下午1点调用方法foo(),我可以使用Timer该类每隔几秒检查一次,如果它是上午9点或下午1点,甚至是Observable.Interval函数.但有更有效的方法吗?所以我不是每隔几秒就检查是否有时间调用foo(),而是一个可以在适当的时候调用foo()的observable.

c# system.reactive

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

Localizable.strings 文件中的 iOS 注释

我正在使用 Xamarin iOS,并且我有一个Localizable.strings文件,用于保存所有字符串。现在它变得非常混乱,想知道是否有办法在此文件中添加注释以更好地组织它?

ios xamarin

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

应用程序处于后台时使用Bloothtooth LE

我正在使用这个BLE插件构建一个带有Xamarin的iOS应用程序:

https://github.com/aritchie/bluetoothle

我只是通过BLE播放UUID,它可以工作.这是我的代码:

var data = new Plugin.BluetoothLE.Server.AdvertisementData
            {
                LocalName = "MyServer",
            };

data.ServiceUuids.Add(new Guid("MY_UUID_HERE"));

await this.server.Start(data);
Run Code Online (Sandbox Code Playgroud)

唯一的问题是,一旦我将应用程序放在后台,它就会停止广播.当我再次打开应用程序时再次恢复.

一旦它在后台,我怎么能让它继续播放?我在这里阅读文档:

https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html

它说我必须使用CBCentralManager该类来获取保存和恢复功能(所以我可以随时继续广播UUID),但我很难将其转换为Xamarin/C#.

编辑

在研究了一些之后,我读到我需要在委托中创建一个实例CBCentralManager并实现WillRestoreState它.我是这样做的AppDelegate:

[Register("AppDelegate")]
public class AppDelegate : MvxApplicationDelegate, ICBCentralManagerDelegate
{
    private IGattServer server = CrossBleAdapter.Current.CreateGattServer();
    private CBCentralManager cbCentralManager;

    public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
    {
        // irrelevant code...

        this.Ble();

        return true;
    }

    private async Task Ble()
    {
        try
        {
            await Task.Delay(5000); // wait for it to finish initializing so I …
Run Code Online (Sandbox Code Playgroud)

xamarin.ios ios xamarin

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

具有Touch ID指纹认证的Xamarin表单

我正在使用Xamarin Forms开发一个多平台应用程序.我需要支持iOS和Android平台的Touch ID /指纹身份验证.我怎样才能做到这一点?我是Xamarin的新手.

xamarin xamarin.forms

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

Xamarin iOS ObserveOrientationDidChange Landscape或Portrait

我需要检测用户何时将设备旋转到横向方向.我可以通过以下代码检测方向何时改变:

UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications();
this.orientationObserver = UIDevice.Notifications.ObserveOrientationDidChange(MyRotationCallback);

private void MyRotationCallback(object sender, NSNotificationEventArgs e)
{
    // Landscape or Portrait ?
}
Run Code Online (Sandbox Code Playgroud)

它有效,但我不知道它是否改为横向或纵向.我怎么能发现这个?

c# xamarin.ios ios xamarin

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

使用 Xamarin 将数据从 iPhone 获取到 Apple Watch

我正在 Xamarin 上开发 iPhone 应用程序,并为 watchOS 3 添加了 Apple Watch 扩展。

我需要将 iPhone 上保存的数据获取到手表扩展。

我只需要获取一次,然后将其保存在手表上,这样就可以在没有 iPhone 的情况下使用它。我怎样才能做到这一点?

编辑

使用 Iain Smith 的WCSessionManager课程解决

c# xamarin.ios xamarin watchkit

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

Xamarin Android深层链接无法正常工作

我正在使用Xamarin开发Android应用程序。我希望能够在用户打开链接时打开应用程序example://gizmos,因此我将其添加到清单文件中:

<activity    android:name="mynamespace.MyActivity"
android:label="@string/application_name" >
<intent-filter android:label="@string/application_name">
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
  <data android:scheme="http"
        android:host="www.example.com"
        android:pathPrefix="/gizmos" />
  <!-- note that the leading "/" is required for pathPrefix-->
  <!-- Accepts URIs that begin with "example://gizmos” -->
  <data android:scheme="example"
        android:host="gizmos" />

</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

这直接取自Android文档。我尝试example://gizmos在我的物理Android设备上单击邮件应用程序中的链接,但收到消息:Unable to find application to perform this action

编辑

它与建议的重复项不同,他们没有使用Xamarin。

android deep-linking xamarin

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

System.InvalidOperationException:页面必须没有父项

在我的Xamarin.Forms应用程序中,我有以下代码:

while (this.Navigation.ModalStack.Count > 0)
{
    await this.Navigation.PopModalAsync();
}

await Navigation.PushModalAsync(App.MyMasterDetailPage.Value);
Run Code Online (Sandbox Code Playgroud)

在最后一行,我得到了错误

System.InvalidOperationException:页面必须没有父项。

MyMasterDetailPage当我把所有东西都弹出后,ModalStack怎么可能有父母?我只推它ModalStack

xamarin.forms

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

创建 View-ViewModel 查找表时出现问题 - 您为 ViewModel 注册了多个视图

我使用 MvvmCross 启动了一个 Xamarin.Froms 项目。我按照官方 MvvmCross 网站上的文档使用 Xamarin.Forms 启动 Android 项目。这是我的Core项目中的代码:

public class App : MvxApplication
{
    public App()
    {

    }

    public override void Initialize()
    {
        base.Initialize();

        Mvx.IoCProvider.RegisterSingleton(new NavigationStack());
        Mvx.IoCProvider.RegisterSingleton<IMvxAppStart>(new MvxAppStart<MainViewModel>(this, Mvx.IoCProvider.Resolve<IMvxNavigationService>()));
    }
}

public class MainViewModel : BaseViewModel
{
    public MainViewModel(NavigationStack navigationStack) : base(navigationStack)
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

我的Forms项目中的 代码MainView.xaml

<views:MvxContentPage x:TypeArguments="viewModels:MainViewModel"
xmlns="http://xamarin.com/schemas/2014/forms" 
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
xmlns:views="clr-namespace:MvvmCross.Forms.Views;assembly=MvvmCross.Forms"
xmlns:mvx="clr-namespace:MvvmCross.Forms.Bindings;assembly=MvvmCross.Forms"
xmlns:viewModels="clr-namespace:MyApp.Core.ViewModels;assembly=MyApp.Core"
x:Class="MyApp.Forms.Views.MainView">

    <ContentPage.Content>
        <StackLayout Margin="10">
            <Label Text="Subtotal" />
        </StackLayout>
    </ContentPage.Content>

</views:MvxContentPage>
Run Code Online (Sandbox Code Playgroud)

MainView.xaml.cs

public partial class MainView : …
Run Code Online (Sandbox Code Playgroud)

mvvmcross xamarin.forms

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