小编Ste*_*oix的帖子

如何使用Interface Builder中的自定义UITableViewCell?

我希望能够在IB中设计我自己的UITableViewCell.但是当我尝试访问我在IB中定义的标签时,我一直得到一个空引用异常.

这是我正在做的事情:

在Interface Builder中:

  • 我删除了"视图"并添加了一个UITableViewCell.
  • 将UITableViewCell的类更改为" TestCellView".
  • 在单元格中添加了UILabel.
  • 为UILabel 添加了一个插座" oLblText" TestCellView并将其连接到它.
  • 将类的标识符更改为"TestCellView".

实现TestCellView.xib.cs

public partial class TestCellView : UITableViewCell
{
    public TestCellView(string sKey) : base(UITableViewCellStyle.Default, sKey)
    {
    }

    public TestCellView(IntPtr oHandle) : base(oHandle)
    {
    }

    public string TestText
    {
        get
        {
            return this.oLblText.Text;
        }
        set
        {
                        // HERE I get the null ref exception!
            this.oLblText.Text = value;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

**TestCellView.designer.cs**

[MonoTouch.Foundation.Register("TestCellView")]
public partial class TestCellView {

    private MonoTouch.UIKit.UILabel __mt_oLblText;

    #pragma warning disable 0169
    [MonoTouch.Foundation.Connect("oLblText")]
    private …
Run Code Online (Sandbox Code Playgroud)

xamarin.ios

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

Android 4.0.4 BLE API,BroadCom - 摩托罗拉

我正在开展医疗保健项目.我们正在进行测试设置,我们使用摩托罗拉Razr Max和Android 4.0.4作为网关.手机的BLE将与IT的BLE芯片通信.选择摩托罗拉Razr maxx的原因是因为IT已将其列在 链接上!哪种手机支持BLE.

但是摩托罗拉的BLE API从android 4.0升级dosnt工作.

我也尝试过手机上的BroadComs BLE API - 但它不支持手机BLE芯片 - 所以我没有在这里得到票价.

所以我的问题在这里.你会建议我从这里做什么?

你知道任何Android手机,其中Broadcoms API我在Android 4.0.4中工作 - IT说HTC 1 X - 有一个工作的BLE API - 有没有尝试过?

如果摩托罗拉正在修复错误,那么有人吗?(摩托罗拉开发者支持团队在丹麦 - 不知道有关自己的软件/硬件.)

------更新--------

我试图让摩托罗拉工作 - 现在它不会失败BLE支持=伟大的:)

我使用的是Motorola_ICS_R2 API.但是,当我运行配置文件样本-它不会编译-因为_ BluetoothDevice.ACTION_GATTBluetoothDevice.EXTRA_GATT是什么荫失踪之前,我可以运行配置文件样本?

android motorola broadcom bluetooth-lowenergy

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

为什么Xamarin.Android在运行时会重建整个解决方案?

我将Xamarin Studio与Xamarin.iOS和Xamarin.Android一起使用。我的工作区包含两种解决方案,一种用于android,另一种用于ios。项目几乎相同。当我为ios构建解决方案时,它仅重建更改的项目。它执行一些额外的操作,而这些操作几乎不需要花费时间。因此,第二次按下Build几乎不需要时间。

但是,当我构建Android解决方案时,它会重建所有项目,而不管文件,配置等方面的更改如何。如果在成功构建后按Build,它将再次重新构建。更糟糕的是,如果我尝试运行刚刚构建的项目,它将对其进行重建!此外,如果我在运行后运行项目(在调试程序时,它经常发生),它将再次重建它。由于我有许多项目,因此需要很长时间,而且编译非常依赖于CPU,因此很难提高速度。

通常,问题是是否有可能在每次构建时都不重新构建整个解决方案?也许我缺少一个配置选项,或者配置错误?

我不知道项目配置中的任何内容是否与问题相关,所以请告诉我解决方案/项目配置的哪一部分可能有所帮助。

版本:

Xamarin Studio
版本4.0.9(内部版本12)
Xamarin.Android
版本:4.7.11(企业版)

//我认为,如今,对于每个严肃的编译器而言,必须进行单独的编译,所以我认为我做错了什么。

UPD:我已经安装了最新版本的Xamarin Studio和Xamarin.Android:

Xamarin Studio
版本4.0.12(内部版本3)
Xamarin.Android
版本:4.8.1(企业版)

重建Android解决方案需要1分58秒。每次我运行应用程序时。

android xamarin.android xamarin-studio

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

MonoTouch中的AesCryptoServiceProvider

我正在使用我的应用程序的iPad版本,我在我使用的功能中有一个功能,AesCryptoServiceProvider例如以下几行

 using (AesCryptoServiceProvider aesProvider = new AesCryptoServiceProvider())
 {
    setAesProviderSettings(aesProvider);
    result = aesProvider.CreateEncryptor().TransformFinalBlock(plainBytes, 0, plainBytes.Length);
 }
Run Code Online (Sandbox Code Playgroud)

它适用于我的Android应用程序(MonDroid)和.NET(WPF)应用程序,但在iOS中我遇到此错误;

Error  5      The type or namespace name 'AesCryptoServiceProvider' could not be found (are you missing a using directive or an assembly reference?)     
Run Code Online (Sandbox Code Playgroud)

该函数在我的核心项目中,我使用项目链接器在iPad项目中引用它,并且我在Android版本中使用项目链接器,当然在三个平台中是相同的文件,其中包含所需的所有引用.我在Visual Studio 12中使用Xamarin.

.net cryptography aes xamarin.ios ios

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

是/否确认UIAlertView

我通常使用以下代码来确认警报

int buttonClicked = -1;
UIAlertView alert = new UIAlertView(title, message, null, NSBundle.MainBundle.LocalizedString ("Cancel", "Cancel"),
                                    NSBundle.MainBundle.LocalizedString ("OK", "OK"));
alert.Show ();
alert.Clicked += (sender, buttonArgs) =>  { buttonClicked = buttonArgs.ButtonIndex; };

// Wait for a button press.
while (buttonClicked == -1)
{
    NSRunLoop.Current.RunUntil(NSDate.FromTimeIntervalSinceNow (0.5));
}

if (buttonClicked == 1)
{
    return true;
}
else
{
    return false;
}
Run Code Online (Sandbox Code Playgroud)

这似乎不适用于iOS7.循环只是继续运行,Clicked事件似乎永远不会被触发.有没有人有一个如何做确认警报的工作示例?

uialertview xamarin.ios xamarin-studio

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

应用程序未在ios 7中的后台运行

我的应用程序在后台运行的iOS 5iOS 6,但在iOS的7它是创造问题.

当我在控制台应用程序中看到继续在后台执行任务时,但是当我点击应用程序进入后台时,应用程序将进入第一个应用程序屏幕(当我们启动应用程序时).在控制台中,它不会告诉应用程序崩溃或类似的东西.它甚至不会打印写入的控制台消息applicationWillEnterForegroundapplicationDidBecomeActive方法.我没有得到这个问题.我正在构建  iOS6并安装应用程序iOS7.请帮忙.

iphone objective-c ipad ios ios7

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

忽略Binding初始化

初始问题来自关于Xamarin.Forms.Map的折线的个人项目,其中初始化是通过XAML部件的绑定实现的.

让我通过一个例子来说明一点:

我有一个 继承自的CustomMap.cs对象Xamarin.Forms.Map (此文件位于PCL部分 - > CustomControl/CustomMap.cs)

public class CustomMap : Map, INotifyPropertyChanged
{
    public static readonly BindableProperty PolylineAddressPointsProperty =
        BindableProperty.Create(nameof(PolylineAddressPoints), typeof(List<string>), typeof(CustomMap), null);
    public List<string> PolylineAddressPoints
    {
        get { return (List<string>)GetValue(PolylineAddressPointsProperty); }
        set
        {
            SetValue(PolylineAddressPointsProperty, value);
            this.GeneratePolylineCoordinatesInner();
        }
    }   
    // ...
}
Run Code Online (Sandbox Code Playgroud)

如您所见,我有一个可评估的可绑定属性,而XAML似乎没有使用此评估器.

因此,调用控件的页面的MainPge.xaml部分如下所示:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:control="clr-namespace:MapPolylineProject.CustomControl;assembly=MapPolylineProject"
         x:Class="MapPolylineProject.Page.MainPage">

  <ContentPage.Content>
    <control:CustomMap x:Name="MapTest" PolylineAddressPoints="{Binding AddressPointList}"
                                       VerticalOptions="Fill" HorizontalOptions="Fill"/>

  </ContentPage.Content>

</ContentPage>
Run Code Online (Sandbox Code Playgroud)

MainPge.xaml.cs部分:

public partial …
Run Code Online (Sandbox Code Playgroud)

xaml binding initialization xamarin xamarin.forms

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

Xamarin - 绑定命令到User Control内对象的属性

我几天前就开始学习XAML了,我遇到了解决这个问题的麻烦.

在Xamarin Forms中,我想创建一个用户控件,它将包含一个标签和一个按钮,并能够将命令绑定到XAML中的usercontrol来自另一个使用我的用户控件的页面.

我目前正在例外:

Xamarin.Forms.Xaml.XamlParseException:'位置8:24.无法分配属性"Test1":属性不存在,或者不可分配,或者值和属性之间的类型不匹配'

这是我目前正在努力工作的一个愚蠢的版本.

我的自定义控件XAML

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="App3.Controls.Control1">
    <StackLayout>
        <Button Command="{Binding Test1}" Text="Test"/>
    </StackLayout>
</ContentView>
Run Code Online (Sandbox Code Playgroud)

使用我的自定义控件XAML进行控制

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:App3"
             xmlns:controls="clr-namespace:App3.Controls"
             x:Class="App3.MainPage">

    <controls:Control1 Test1="{Binding Test2}" />
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

我的自定义控件代码隐藏

using System.Windows.Input;
using Xamarin.Forms;

namespace App3.Controls
{
    public partial class Control1 : ContentView
    {

        private static readonly BindableProperty controlProperty = BindableProperty.Create("Test1", typeof(ICommand), typeof(Control1), null);

        public Control1()
        {
            InitializeComponent();
        }

        public ICommand Test1
        {
            get
            {
                return (ICommand)GetValue(controlProperty);
            }
            set
            {
                SetValue(controlProperty, value); …
Run Code Online (Sandbox Code Playgroud)

c# xaml xamarin xamarin.forms

5
推荐指数
2
解决办法
5025
查看次数

Xamarin表单:具有可绑定属性的IMarkupExtension不起作用

绑定不适用于Image标记.当我调试时,我看到Extension类中的Source值始终为null?但标签的内容不是空的.

XAML

<Label Text="{Binding Image}" />
<Image Source="{classes:ImageResource Source={Binding Image}}" />
Run Code Online (Sandbox Code Playgroud)

ImageResourceExtension

// You exclude the 'Extension' suffix when using in Xaml markup
[Preserve(AllMembers = true)]
[ContentProperty("Source")]
public class ImageResourceExtension : BindableObject, IMarkupExtension
{
    public static readonly BindableProperty SourceProperty = BindableProperty.Create(nameof(Source), typeof(string), typeof(string), null);
    public string Source
    {
        get { return (string)GetValue(SourceProperty); }
        set { SetValue(SourceProperty, value); }
    }

    public object ProvideValue(IServiceProvider serviceProvider)
    {
        if (Source == null)
            return null;

        // Do your translation lookup here, using whatever method you …
Run Code Online (Sandbox Code Playgroud)

binding bindable xamarin xamarin.forms

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

无法在Xaml上设置嵌套类的属性

Xamarin给出的错误:在xmlns clr-namespace中找不到类型Foo:AmsterdamTheMapV3

问题是我正在尝试定义Foo,但无论我做什么,它都会起作用.我认为问题出在xmls:local命名空间内.也许我在代码中犯了一个愚蠢的错误.

这是一个用于windows,android和apple的Xamarin.forms项目.

Xaml文件:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="AmsterdamTheMapV3.CityGuide"
             xmlns:local="clr-namespace:AmsterdamTheMapV3">
  <Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
  <ScrollView Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
    <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"  Spacing="0">

      <!-- Button1 -->
      <Image
          x:Name="CityGuideButton1"
          Source="shopping_gray.png"
          Aspect="Fill"
          HorizontalOptions="FillAndExpand"
                VerticalOptions ="FillAndExpand"
          local:Foo.Tag="button1">
        <Image.GestureRecognizers>
          <TapGestureRecognizer
            Tapped="Categorie_Onclick"
            NumberOfTapsRequired="1"/>
        </Image.GestureRecognizers>
      </Image>
    </StackLayout>
  </ScrollView>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

Cs文件:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;

namespace AmsterdamTheMapV3
{
    public partial class CityGuide : ContentPage
    {
        public CityGuide()
        {
            InitializeComponent();
        }

         public class Foo …
Run Code Online (Sandbox Code Playgroud)

c# xaml android xamarin xamarin.forms

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