Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

Improved life cycle support

$
0
0

Summary

As one of the authors of ReactiveUI, I have found that Xamarin.Forms does not provide the requisite view life cycle hooks to enable the framework to manage the activation and deactivation of resources in response to the comings and goings of views.

Specifically, I have found these problems:

  • Page.Appearing actually fires in response to ViewDidAppear on iOS. One of ReactiveUI's benefits is its code-based, type-safe binding infrastructure. Appearing is the only hook we can use to get stuff on the screen, but it fires too late on iOS, so there is a brief period where the screen is not populated with data. I have already attempted to start a discussion here, but it seemed to stagnate.

  • Given a View, there is no way to tell when that View appears and disappears from the screen. There is no View.Appearing or View.Disappearing events as there is for Page. It might seem appropriate to therefore search up the visual tree for the Page and hook into that. However, this is inefficient (but perhaps that's inevitable) and there is no means of knowing when the Page itself changes. There is no PageChanged event, and PropertyChanged does not fire in response to the Page changing.

API Changes

  • Page.Appearing should fire in response to ViewWillAppear on iOS. Moreover, there should be Page.Appeared and Page.Disappeared counterparts. Yes, this is potentially breaking to people who are hooked into Appearing and rely on it firing in response to ViewDidAppear on iOS. However, that behavior has always been incorrect and the fix for these people is literally to change Appearing to Appeared (or hold off on the XF upgrade).

  • Ideally, add Appearing, Appeared, Disappearing, Disappeared to View and have them Just Work. Failing that, ensure there is a hook by which framework authors can know the hosting Page for a View has changed. Perhaps a specific PageChanged event, or just ensuring PropertyChanged works as expected in this scenario.

Intended Use Case

The use case here is to give framework authors what they need to facilitate the creation of self-sufficient, standalone, encapsulated components by framework consumers. I specifically work on ReactiveUI, but other framework authors will/have run into the same issues.

ModEdit - Spec incoming ASAP


Intermittent "Unable to connect to a test backend" iOS Simulator

$
0
0

I have a bunch of tests which are running fine about 60% of the time, but other times they will simply fail with the the "Unable to connect to a test backed running app" exception. Now, because this is not happening on every single run, I don't think this is a setup/configuration issue.

  • ENABLE_TEST_CLOUD symbol is set for the Debug configuration of the iOS app

  • Xamarin.Calabash.Start() is called in AppDelegate.cs

  • The Unit Tests pad/Test Apps link has been created to the iOS app
  • XCode 8.1
  • iOS 10.1 running in the iOS Simulator
  • Xamarin.UITest v2.0.1
  • Xamarin.TestCloud.Agent v0.20.3
  • Xamarin Studio 6.1.2 build 44 (Beta channel)

Again, tests might run just fine on first run, and fail on second. A try...catch block wrapping the StartApp() call shows that the exception is (of course) raised there.

Any kind of help appreciated, thanks.

Weird unrecognized selector error in one project, not in the other

$
0
0

Hi,

I'm currently in the process of making a Xamarin Forms PDF viewing component for internal use in my company, based on RadaeePDF SDK.

The iOS SDK gives us a .a library, probably written in C, and a few Obj-C classes (with source) to wrap around it to have it in nice, iOS views. So, I've compiled the project into a .a, made a new binding library, and a new Xamarin.iOS class library to host my Forms renderer.

Naturally, I've made a sample project that uses the component. So far, so good, it all works.

However, the first time we integrated the component into one of our existing Forms app, I've hit a "unrecognized selector" error in the existing project, even though the code is strictly similar.

The error is the following:

2017-01-31 12:08:03.549 BatiScriptLiteiOS[736:535362] -[PDFView vOpen::]: unrecognized selector sent to instance 0x1802e7b0

but it seems any PDFView method results in a similar crash. The PDFView class is used internally by the component and is not part of the exposed API.

The API definition is the following (I trimmed out a few methods):

    [BaseType (typeof(UIScrollView))]
    interface PDFView : PDFVInnerDel, IUIScrollViewDelegate, IUIPickerViewDelegate, IUIPickerViewDataSource
    {
        [Export("initWithFrame:")]
        IntPtr Constructor(CGRect frame);

        [Export ("vOpen::")]
        void vOpen(PDFDoc doc, [NullAllowed] PDFViewDelegate deleg);

        [Export ("vGetDocWidth")]
        int DocWidth { get; }
        [Export ("vGetDocHeight")]
        int DocHeight { get; }
    }
[BaseType (typeof(NSObject))]
interface PDFDoc
{

    // -(int)openStream:(id<PDFStream>)stream :(NSString *)password;
    [Export ("openStream::")]
    int OpenStream (PDFStream stream, [NullAllowed] string password);
}

And the code in the renderer:

var page = e.NewElement;
_pdfView = new PDFView(new CoreGraphics.CGRect(0, 0, NativeView.Bounds.Width, NativeView.Bounds.Height));
SetNativeControl(_pdfView);
_pdfView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
var src = await page.DocumentAsyncSrc();
PDFDoc doc = new PDFDoc();
doc.OpenStream(new StreamWrapper() { Src = src }, null);
_pdfView.vOpen(doc, new PdfViewEventListener() { ToUpdate = page }); // This call crashes in the non-sample app
// The PDFViewEventListener is a C# impl of an objC protocol, as is the StreamWrapper

I've tried quite a few things, to no avail. The selector error occurs on iPhone, iPad, and simulator. I've changed the linking all through None, SDK only and full, as it seems it is the likeliest culprit.

Anyone has any idea ?

Bonus points to those who tell me why there is no exception thrown AFAICT.

Thanks in advance

Debugging Android

$
0
0

Yesterday I got an error while try to debug wich says "Debug will disabled" because of this error. Now I need to debug some stuff becuase I got a wired error on Android. But the break points are not hit. I cannot find anything how I can "activate" debugging. In the iOS part of my forms application the debugging still works fine. I already tried "[Application(Debuggable=true)]" but it changed nothing. Also a new checkout of my repository (without any temp files like *.suo, *.user or bin and obj folder) changed nothing. The debugging does not work at all. But in a complete different application the debugging works also for Android just fine so I guess it must be some change in the project files itself because of that error.

Navigation Drawer starting template

$
0
0

Why is not there a automatic option for creating a Navigation Drawer Activity instead of do it manually?

Android Studio has it, and also a lot of other, such like Login Activity, Maps... etc.

I used to use an template, but now it gives me a lot of errors on Xamarin (VS).

It must have in Xamarin, since it saves a lot of time and is essential for Android Apps.

Here is the template I used to use:

https://marketplace.visualstudio.com/items?itemName=vs-publisher-473885.XamarinAndroidTemplatesPack

How to define boolean key in app.xaml?

$
0
0

How to define a global resource dictionary boolean key, ShowMyMenu, and use it to show or hide myMenu

<local:myMenu x:Name="myMenu" HorizontalOptions="FillAndExpand" VerticalOptions="Start" IsVisible="{StaticResource ShowMyMenu}" />

I tried same different ways in App.xaml file, but they can't be executed:

<x:bool x:key="ShowMyMenu">True</x:bool>

<x:Boolean x:key="ShowMyMenu">True</x:Boolean>

<Boolean x:key="ShowMyMenu">True</Boolean>

Thanks for your help

Unable to see "Generate Step Definition" context menu for xamarin studio

$
0
0

HI,
I am working on creating a specflow . After creating the feature, I want to generate the specdefinition directly . But I don't see any option.
I can see the contextmenu on visual studio but not on xamarin studio.
My xamarin studio version is 6.1.2 build 44

Top Visible Table Cell Not Updating After ReloadData Called

$
0
0

I am currently developing an application using MvvmCross and Xamarin iOS. The main view of the application is split into two. The lower half of the view is a table view.

The table view is populated by an async proses that works correctly.

If a user taps to select the item, they are navigated to another view that enables them to update the selected item. The update causes the data source to be reloaded (as the edit may have affected other items) and the table view to reload.

The table view is not in view during the reload process; however the reload is performed on the main thread.

In all cases this works correctly, apart from when the top visible row is selected. In this instance the cell is never updated. Each time it is selected for reuse the view renders with the initial data that it was created with.

From the console output I can see that prepare for reuse is being invoked on all of the cells. I can also confirm that the reload operation on the table is being invoked on the main thread.

The table data source (extended from MvxSimpleTableSource) does invoke the overload for GetOrCreateCellFor and the data for the bound items is updated. All of my investigations have not been able to resolve the issue.

Please can anyone help.


How To Bind Picker in C#

$
0
0

how to bind picker without using bindable Property? i dont need in xml, i want to be done in class.

Open Universal Link from within an app with OpenUrl

$
0
0

We have an iOS app that is configured to open universal links.
This works fine. When clicking on urls from a browser, notes or email-application, the app is opened and the correct action is taken.

However, these urls also occur within our app as labels that have a TapGestureRecognizer which opens the url as follows:

UIApplication.SharedApplication.OpenUrl(Uri);

When the label is tapped, that the url is opened in Safari, which then shows an app banner that allows the users to open it with the app.

I would expect it to open with the same app.

I did find a property on UIApplicationOpenUrlOptions: UniversalLinksOnly. This page http://useyourloaf.com/blog/openurl-deprecated-in-ios10/ definies this as follows:

Use a boolean value set to true (YES) to only open the URL if it is a valid universal link with an application configured to open it. If there is no application configured or the user disabled using it to open the link the completion handler is called with false (NO).

I tried this:

var options = new UIApplicationOpenUrlOptions ();
options.UniversalLinksOnly = true;
UIApplication.SharedApplication.OpenUrl(new Foundation.NSUrl(url.AbsoluteUri), options, null);

Strangely this blocks the url from opening at all, which would imply that the app is not registered. However opening the links from other apps works without problems, suggesting that the app is registered.

How can we get universal links from within an app to open with the same app?

Use a third party library in C

$
0
0

Hello,
From a Xamarin project how to call for a library written in pure C.
Thank you,
Christophe

Open an image file

$
0
0

Hello,

How to open an image file that is in the mobile, like a selphie, from a xamarin application,
and second how to view the camera and freeze the image?
Thank you,
Christophe,

Problems with runtime permission dialog

$
0
0

Hey!

There seems to be an issue with asking runtime permissions. I've tested it several ways in both Android Studio and Xamarin Studio.

If the minimum android version is set (target version doesn't matter, but 7.0 in my case), the permission dialog is not shown when RequestPermissions() or ActivityCompat.RequestPermissions()is called, instead, it instantly calls OnRequestPermissionsResult with grantResults empty. I can provide the code if necessary, but it's easily reproducible.

When I simply remove the line <uses-sdk android:minSdkVersion="15", so that minimum and target minimum android version defaults to API 24, everything works -- but, obviously, this is not a solution.

Note that I am using Xamarin.Android.Support.v7.AppCompat library with a normal Activity as base class, not AppCompatActivity. Same approach works fine in Android Studio. And I have, yes, set the permissions in the manifest as well.

So, what's going on here? I'm losing my mind.

Best wishes,
Aare

Listview with images

$
0
0

Hello,
How to create a ListView with images, how to create a custom renderer for listview items?
Thank you,
Christophe

MAC Android Emulators from Visual Studio in Parallels

$
0
0

Hi All,

I am trying to get my Parallels Visual Studio install to talk to the Android Studio Emulators on my MAC (for whatever reason I am struggling to start the windows ones as they ask for Hyper-V or whatever etc).

I have followed the steps in this guide.

https://taco.visualstudio.com/en-us/docs/run-android-emulator-on-osx-using-parallels/

And after I run the putty SSH script to connect to the MAC, I cannot see any emulators using adb devices.

If I run - adb connect localhost:5555 I then see on adb devices -

C:\Users\matthewwaring>adb devices
List of devices attached
emulator-5554 offline

So its sort of connecting, but the device is registering as offline and I cannot seem to do anything to get it online so it could
show up in the VS Device list.

Does anyone have experience of this who could help out as pretty stuck?

Thanks for your help
Matt


Is it possible to create a fully-programmatic custom UITableViewCell without having to use .xib?

$
0
0

Programming natively with Swift, I can create a custom table view cell by inheriting UITableViewCell and overriding methods such as init() - But I'm in a world of pain trying to replicate this in Xamarin.

I don't want to have to rely on a xib to create the cell, I'd much rather be able to subclass it in the same way that I can subclass a UIView and override the draw() etc.

Can anyone point me in the direction of examples? Or does almost everyone subscribe to the WYSIWYG way of doing things?

Audio issue

$
0
0

I am using MPMoviePlayerController class to play a video. Video is showing properly but no audio I am getting for iPad 9.3.5. But when ever I am playing on iPhone (8.4.1) player is working properly.

Toolbar title set center align.

$
0
0

how can i title will be set center align in toolbar using Android layout.

Binding by parameter using LINQ

$
0
0

I have these class:
https://codepaste.net/ciadta

In my Page.xaml, I'd like to bind only messages from a especific conversation.
For example, when user access a conversation with "To" = 456, only messages from this conversation would be displayed.

So, I can't use simply {Binding Conversation}, because it has the attribute "To" and "Messages", and it wouldn't bind its messages.

Theorically, I'd like to user something like this:
var currentConversation = Conversations.Single(c => c.To == SelectedUser.Id.ToString());
CurrentMessages = new ObservableCollection(currentConversation.Messages);

But it's not the best way, because new messages will be load in realtime, thus it'd be needed to upated CurrentMessages everytime Conversation receive new messages from server.

Can anyone help me?
Thank you.

I can't debug iOS app on device from Visual Studio

$
0
0

Hi,

I have Visual Studio 2015 on Windows 10 64-bit.
And I have a Xamarin multiplatform project for iOS, Android, WinPhone 8.1, and Windows 8.1.

Now I try to debug the iOS project on the device (iPhone 4).
I have the Mac Mini with the latest MacOS X El Capitan, and the latest SDK's, XCode, and Xamarin Studio with Xamarin.iOS Build Host.
Also I have Development Provisioning Profile and Certificate that are installed through XCode from Apple Developer account.

But I get only a message "0 of 1 Error" in the VS "Error List" pane after I start a debugging process, and nothing else.
And unfortunately I have no "Mac Server Log" option in the VS "Output" pane.

But I get an error log on the Mac in the "~/Library/Logs/Xamarin/MonoTouchVS/mtbserver.log" file.
And the is a part of this log in the attachment (see file mtbserver.log.txt).

As I can see there are two problems:

The first

[21-Oct-2015 17:40:19] Error: Error accepting log connection from Visual Studio
[21-Oct-2015 17:40:19] Exception: Exception type: System.ObjectDisposedException
The object was used after being disposed.
at System.Net.Sockets.Socket.EndAccept (System.Byte[]& buffer, System.Int32& bytesTransferred, IAsyncResult asyncResult) [0x00000] in :0
at System.Net.Sockets.Socket.EndAccept (IAsyncResult result) [0x00000] in :0
at Mtb.Server.Proxy.LogProxy.VS_IncomingOutput (IAsyncResult result) [0x00000] in :0

and the second

[21-Oct-2015 17:41:00] stderr: error MT1006: Could not install the application
'/Users/admin/Library/Caches/Xamarin/mtbs/builds/MyAppiOS/3aaef0795321ed14930c548d9a5ff21a/bin/iPhone/Debug/MyAppiOS.app'
on the device MyiPhone4: AMDeviceSecureInstallApplicationBundle returned: 0xe800801c.

But maybe I'm mistaken. I'm a novice in the iOS development.

Could you help me please?
Thank you in advance!

And what about "Mac Server Log" option in the VS "Output" pane? How can I enable it?

Best Regards,
Aleksandrs

Viewing all 204402 articles
Browse latest View live