Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Need Help on XLabs.Forms.Controls.ImageButton() Control

$
0
0

I am using the XLabs.Forms.Controls.ImageButton() Control using XLabs.Forms package 2.0

Problem:
The following code works fine for Android, but in iOS it throws the error during runtime.

Error as follows:

2015-09-11 10:48:45.110 XLabsTestProjectiOS[20926:1078476] Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): no suitable image found. Did find:
/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: mach-o, but not built for iOS simulator
2015-09-11 10:48:45.110 XLabsTestProjectiOS[20926:1078476] Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0x7b230230 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)

The image icon.png are present in both the Resources folder.

I have tried with multiple option using Device Platform method. but the same error. kindly assist on this

Source = Device.OnPlatform(
iOS: ImageSource.FromFile("icon.png"),
Android: ImageSource.FromFile("icon.png"),
WinPhone: ImageSource.FromFile("icon.png"))

Step-1

Added the Package from NuGet XLabs.Forms for both the version Android and iOS.

Step-2

Add Andriod : MainActivity.cs

using System;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

using XLabs.Forms;

namespace XLabs.Test.Project.Droid
{
[Activity (Label = "XLabs.Test.Project.Droid", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

** public class MainActivity : XFormsApplicationDroid
** {
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

global::Xamarin.Forms.Forms.Init (this, bundle);

LoadApplication (new App ());

}
}
}

Step-3

iOS : AppDelegate.cs

using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;

using XLabs.Forms;

namespace XLabs.Test.Project.iOS
{
[Register ("AppDelegate")]

** public partial class AppDelegate : XFormsApplicationDelegate**
{
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init ();

// Code for starting up the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
Xamarin.Calabash.Start();
#endif

LoadApplication (new App ());

return base.FinishedLaunching (app, options);

}
}
}

Step-4

using System;
using Xamarin.Forms;
using XLabs.Forms.Controls;
using XLabs.Enums;

namespace XLabs.Test.Project
{
public class ContPage : ContentPage
{
public ContPage ()
{
var pickupbtn = new XLabs.Forms.Controls.ImageButton() {
ImageHeightRequest = 120,
ImageWidthRequest = 120,
BackgroundColor=Color.White,
Orientation = ImageOrientation.ImageToLeft,
Source = "icon.png"
};

pickupbtn.Clicked += ButtonClick;

var layout = new StackLayout { 
    Spacing = 16, 
    VerticalOptions = LayoutOptions.FillAndExpand,
    Children = {pickupbtn}
};
this.Content = layout;

}

private void ButtonClick(object sender, EventArgs e)
{
var button = sender as ImageButton;
this.DisplayAlert("Button Pressed", string.Format("The {0} button was pressed.", button.Text), "OK",
"Cancel");
}
}


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>