In this webinar deck Craig Dunn shows what’s new in iOS 11 and how to take advantage of the latest updates – from drag-and-drop for iPad to machine learning and more – 100% in .NET and Visual Studio. Whether you’re building new or updating existing Xamarin.iOS apps, you’ll see how to implement new frameworks, APIs, and UI features, walk-through code samples, get expert tips and tricks, so you can start shipping iOS 11-ready apps to your users.
Watch webinar at https://youtu.be/mXAbpXLT1vo
22.
var context = new LAContext();
// Face ID or Touch ID
context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out var err1)
context.BiometryType == LABiometryType.TouchId ? "Touch ID" : "Face ID"
// PIN/Password
context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out var err2)
23.
var context = new LAContext();
// Face ID or Touch ID
context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out var err1)
context.BiometryType == LABiometryType.TouchId ? "Touch ID" : "Face ID"
context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason,
replyHandler);
// PIN/Password
context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out var err2)
context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, localizedReason, replyHandler);
26.
public UIDragItem[] GetItemsForBeginningDragSession(UITableView tableView,
IUIDragSession session, NSIndexPath indexPath)
{
var data = NSData.FromString(todoItems[indexPath.Row], NSStringEncoding.UTF8);
var itemProvider = new NSItemProvider();
itemProvider.RegisterDataRepresentation(UTType.PlainText,
NSItemProviderRepresentationVisibility.All,
(completion) =>
{
completion(data, null);
return null;
});
var dragItem = new UIDragItem(itemProvider);
return new UIDragItem[] { dragItem };
}
27.
public bool CanHandleDropSession(UITableView tableView, IUIDropSession session)
{
return session.CanLoadObjects(typeof(NSString));
}
public UITableViewDropProposal DropSessionDidUpdate(UITableView tableView,
IUIDropSession session, NSIndexPath destinationIndexPath)
{
if (tableView.HasActiveDrag) {
// moving in current app
} else {
return new UITableViewDropProposal(UIDropOperation.Copy,
UITableViewDropIntent.InsertAtDestinationIndexPath);
}
}
28. public void PerformDrop(UITableView tableView, IUITableViewDropCoordinator coordinator)
{
// determine path from coordinator.DestinationIndexPath
coordinator.Session.LoadObjects<NSString>((items) =>
{
tableView.BeginUpdates();
foreach (var i in items)
{
// add items to table and data store
}
tableView.EndUpdates();
};
}
32.
// ClusterView : MKMarkerAnnotationView
var renderer = new UIGraphicsImageRenderer(new CGSize(40, 40));
var count = cluster.MemberAnnotations.Length;
var notDoneCount = CountByType(cluster.MemberAnnotations, MarkerType.NotDone);
Image = renderer.CreateImage((context) => {
// Fill full circle with tricycle color
TodoView.DoneColor.SetFill();
UIBezierPath.FromOval(new CGRect(0, 0, 40, 40)).Fill();
... Custom drawing
33.
// MapView.GetViewForAnnotation
if (annotation is TodoAnnotation) {
//...
}
else if (annotation is MKClusterAnnotation) {
var cluster = annotation as MKClusterAnnotation;
var view = mapView.DequeueReusableAnnotation
(MKMapViewDefault.ClusterAnnotationViewReuseIdentifier) as ClusterView;
if (view == null) {
view = new ClusterView(cluster,
MKMapViewDefault.ClusterAnnotationViewReuseIdentifier);
}
return view;
}
37. // Load
var assetPath = NSBundle.MainBundle.GetUrlForResource("VGG16.mlmodelc");
var model = MLModel.Create(assetPath, out err);
// Classify
var inputs = new NSDictionary<NSString, NSObject> (new NSString("image"), imageValue);
var inputFeatures = new MLDictionaryFeatureProvider (inputs, out error);
var outFeatures = model.GetPrediction (inputFeatures, out error2);
var predictionsDictionary = outFeatures.GetFeatureValue ("classLabelProbs").DictionaryValue;