get the most out of ios 11 with visual studio tools for xamarin

45

Upload: xamarin

Post on 21-Jan-2018

260 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 2: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 3: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 4: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 5: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

aka.ms/xamarin/ios11-todo11

Page 6: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 7: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 8: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

// UINavigationControllerNavigationBar.PrefersLargeTitles = true;

// UIViewController (second one in stack)NavigationItem.LargeTitleDisplayMode = UINavigationItemLargeTitleDisplayMode.Never;

// AppDelegateUINavigationBar.Appearance.LargeTitleTextAttributes = new UIStringAttributes{

ForegroundColor = UIColor.FromRGB(0x5A, 0x86, 0x22), // 5A8622 dark-green};

Page 9: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 10: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

new

Page 11: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 12: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

SafeAreaLayoutGuide

Page 13: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

MarginLayoutGuide

Page 14: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 15: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 16: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

Safe Area var safeGuide = View.SafeAreaLayoutGuide;

NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {CloseButton.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor, -23),CloseButton.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor, -13),CloseButton.WidthAnchor.ConstraintEqualTo(60),CloseButton.HeightAnchor.ConstraintEqualTo(60)

});

-23

-13

Page 17: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

var safeGuide = View.SafeAreaLayoutGuide;

NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {CloseButton.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor, -23),CloseButton.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor, -13),CloseButton.WidthAnchor.ConstraintEqualTo(60),CloseButton.HeightAnchor.ConstraintEqualTo(60)

});

Page 18: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { CameraButton.TrailingAnchor.ConstraintEqualTo(CloseButton.LeadingAnchor, -23), CameraButton.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor, -13), CameraButton.WidthAnchor.ConstraintEqualTo(60), CameraButton.HeightAnchor.ConstraintEqualTo(60)

});

Safe Area

-23

-13

Page 19: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

-13

var marginGuide = View.LayoutMarginsGuide;

NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { ClassificationLabel.LeadingAnchor.ConstraintEqualTo(marginGuide.LeadingAnchor), ClassificationLabel.TrailingAnchor.ConstraintEqualTo(marginGuide.TrailingAnchor), ClassificationLabel.BottomAnchor.ConstraintEqualTo(CloseButton.TopAnchor, -13), ClassificationLabel.HeightAnchor.ConstraintEqualTo(120)

});

MarginMargin

Page 20: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 21: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 22: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

var context = new LAContext();

// Face ID or Touch IDcontext.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out var err1)

context.BiometryType == LABiometryType.TouchId ? "Touch ID" : "Face ID"

// PIN/Passwordcontext.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out var err2)

Page 23: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

var context = new LAContext();

// Face ID or Touch IDcontext.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out var err1)

context.BiometryType == LABiometryType.TouchId ? "Touch ID" : "Face ID"

context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason, replyHandler);

// PIN/Passwordcontext.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, out var err2)

context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthentication, localizedReason, replyHandler);

Page 24: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 25: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 26: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

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 };

}

Page 27: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

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);

}}

Page 28: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

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();

};}

Page 29: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 30: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 31: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

// MKMarkerAnnotationViewClusteringIdentifier = "todo";

// ViewDidLoadMapView.Register(typeof(TodoView),MKMapViewDefault.AnnotationViewReuseIdentifier);MapView.Register(typeof(ClusterView),MKMapViewDefault.ClusterAnnotationViewReuseIdentifier);

Page 32: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

// ClusterView : MKMarkerAnnotationViewvar 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 colorTodoView.DoneColor.SetFill();UIBezierPath.FromOval(new CGRect(0, 0, 40, 40)).Fill();... Custom drawing

Page 33: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

// MapView.GetViewForAnnotationif (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;

}

Page 34: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 35: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

customvision.ai

Page 36: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

developer.apple.com/machine-learning/

Page 37: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

// Loadvar assetPath = NSBundle.MainBundle.GetUrlForResource("VGG16.mlmodelc");

var model = MLModel.Create(assetPath, out err);

// Classifyvar 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;

Page 38: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 39: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

Info.plist

developer.apple.com/support/app-store/

Page 40: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)){

context.LocalizedReason = "Authorize for access to secrets";}

Page 41: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

if (picker.RespondsToSelector(new Selector("setPredicateForEnablingPerson:")))

{picker.PredicateForEnablingPerson = NSPredicate.FromFormat

("emailAddresses.@count > 0");}

Page 42: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Page 43: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

aka.ms/xamarin/ios11-todo11

aka.ms/xamarin/ios11

aka.ms/xamarin/ios11-samples

visualstudio.com/xamarin

Page 44: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin

Craig Dunn

Microsoft Docs

Page 45: Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin