summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-04-17 12:33:52 -0700
committerJason Smith <jason.smith@xamarin.com>2016-04-17 12:33:52 -0700
commit0b10ab0c130c814b4ab1595c8d13c4c6c9c9d5df (patch)
tree1518a50c966caced55e4cc4b4d80e6a9c5636fc4
parent2223efdd4ff740a9335cd0a41f0c0e406568ed3d (diff)
downloadxamarin-forms-0b10ab0c130c814b4ab1595c8d13c4c6c9c9d5df.tar.gz
xamarin-forms-0b10ab0c130c814b4ab1595c8d13c4c6c9c9d5df.tar.bz2
xamarin-forms-0b10ab0c130c814b4ab1595c8d13c4c6c9c9d5df.zip
Fix bugzilla39987 (#100)
* [Controls] Add repo for bugzilla 39987 * Fix repo * Resolve issue with blank first tab in iOS 9.3
-rw-r--r--Xamarin.Forms.ControlGallery.iOS/CustomRenderers.cs88
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39987.cs49
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.iOS/VisualElementTracker.cs2
4 files changed, 119 insertions, 21 deletions
diff --git a/Xamarin.Forms.ControlGallery.iOS/CustomRenderers.cs b/Xamarin.Forms.ControlGallery.iOS/CustomRenderers.cs
index a71a48cf..d5787865 100644
--- a/Xamarin.Forms.ControlGallery.iOS/CustomRenderers.cs
+++ b/Xamarin.Forms.ControlGallery.iOS/CustomRenderers.cs
@@ -9,12 +9,16 @@ using System.Drawing;
#if __UNIFIED__
using UIKit;
+using MapKit;
+using CoreLocation;
using Foundation;
using RectangleF = CoreGraphics.CGRect;
#else
using MonoTouch.UIKit;
using MonoTouch.Foundation;
+using MonoTouch.MapKit;
+using MonoTouch.CoreLocation;
#endif
[assembly: ExportRenderer(typeof(Bugzilla21177.CollectionView), typeof(CollectionViewRenderer))]
@@ -22,8 +26,54 @@ using MonoTouch.Foundation;
[assembly: ExportRenderer(typeof(NativeCell), typeof(NativeiOSCellRenderer))]
[assembly: ExportRenderer(typeof(NativeListView2), typeof(NativeiOSListViewRenderer))]
[assembly: ExportRenderer(typeof(NativeListView), typeof(NativeListViewRenderer))]
+[assembly: ExportRenderer(typeof(CustomMapView), typeof(CustomIOSMapRenderer))]
+
namespace Xamarin.Forms.ControlGallery.iOS
{
+ public class CustomIOSMapRenderer : ViewRenderer<CustomMapView, MKMapView>
+ {
+ private MKMapView _mapView;
+
+ protected override void OnElementChanged(ElementChangedEventArgs<CustomMapView> e)
+ {
+ base.OnElementChanged(e);
+
+ if (e.NewElement != null)
+ {
+ if (Control == null)
+ {
+ _mapView = new MKMapView(UIScreen.MainScreen.Bounds);
+ _mapView.MapType = MKMapType.Standard;
+ _mapView.RotateEnabled = false;
+ SetNativeControl(_mapView);
+ }
+
+ }
+
+ CLLocationCoordinate2D coords = new CLLocationCoordinate2D(48.857, 2.351);
+ MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(20), MilesToLongitudeDegrees(20, coords.Latitude));
+ _mapView.Region = new MKCoordinateRegion(coords, span);
+ }
+
+ public double MilesToLatitudeDegrees(double miles)
+ {
+ double earthRadius = 3960.0; // in miles
+ double radiansToDegrees = 180.0 / Math.PI;
+ return (miles / earthRadius) * radiansToDegrees;
+ }
+
+ public double MilesToLongitudeDegrees(double miles, double atLatitude)
+ {
+ double earthRadius = 3960.0; // in miles
+ double degreesToRadians = Math.PI / 180.0;
+ double radiansToDegrees = 180.0 / Math.PI;
+ // derive the earth's radius at that point in latitude
+ double radiusAtLatitude = earthRadius * Math.Cos(atLatitude * degreesToRadians);
+ return (miles / radiusAtLatitude) * radiansToDegrees;
+ }
+ }
+
+
public class NativeiOSCellRenderer : ViewCellRenderer
{
static NSString s_rid = new NSString("NativeCell");
@@ -77,13 +127,15 @@ namespace Xamarin.Forms.ControlGallery.iOS
_imageView = new UIImageView();
- _headingLabel = new UILabel() {
+ _headingLabel = new UILabel()
+ {
Font = UIFont.FromName("Cochin-BoldItalic", 22f),
TextColor = UIColor.FromRGB(127, 51, 0),
BackgroundColor = UIColor.Clear
};
- _subheadingLabel = new UILabel() {
+ _subheadingLabel = new UILabel()
+ {
Font = UIFont.FromName("AmericanTypewriter", 12f),
TextColor = UIColor.FromRGB(38, 127, 0),
TextAlignment = UITextAlignment.Center,
@@ -130,13 +182,15 @@ namespace Xamarin.Forms.ControlGallery.iOS
_imageView = new UIImageView();
- _headingLabel = new UILabel() {
+ _headingLabel = new UILabel()
+ {
Font = UIFont.FromName("Cochin-BoldItalic", 22f),
TextColor = UIColor.FromRGB(127, 51, 0),
BackgroundColor = UIColor.Clear
};
- _subheadingLabel = new UILabel() {
+ _subheadingLabel = new UILabel()
+ {
Font = UIFont.FromName("AmericanTypewriter", 12f),
TextColor = UIColor.FromRGB(38, 127, 0),
TextAlignment = UITextAlignment.Center,
@@ -270,10 +324,7 @@ namespace Xamarin.Forms.ControlGallery.iOS
public IEnumerable<DataSource> Items
{
//get{ }
- set
- {
- _tableItems = value.ToList();
- }
+ set { _tableItems = value.ToList(); }
}
public NativeiOSListViewSource(NativeListView2 view)
@@ -336,7 +387,8 @@ namespace Xamarin.Forms.ControlGallery.iOS
, _tableItems[indexPath.Row].Category
, null);
}
- else {
+ else
+ {
cell.UpdateCell(_tableItems[indexPath.Row].Name
, _tableItems[indexPath.Row].Category
, UIImage.FromFile("Images/" + _tableItems[indexPath.Row].ImageFilename + ".jpg"));
@@ -355,10 +407,7 @@ namespace Xamarin.Forms.ControlGallery.iOS
public IEnumerable<string> Items
{
- set
- {
- _tableItems = value.ToList();
- }
+ set { _tableItems = value.ToList(); }
}
public NativeListViewSource(NativeListView view)
@@ -379,6 +428,7 @@ namespace Xamarin.Forms.ControlGallery.iOS
return _tableItems.Count;
}
#endif
+
#region user interaction methods
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
@@ -411,7 +461,7 @@ namespace Xamarin.Forms.ControlGallery.iOS
cell = new UITableViewCell(UITableViewCellStyle.Subtitle, _cellIdentifier);
// set the item text
- cell.TextLabel.Text = _tableItems[indexPath.Row];//.Items[indexPath.Row].Heading;
+ cell.TextLabel.Text = _tableItems[indexPath.Row]; //.Items[indexPath.Row].Heading;
// if it's a cell style that supports a subheading, set it
// if(item.CellStyle == UITableViewCellStyle.Subtitle
@@ -449,7 +499,8 @@ namespace Xamarin.Forms.ControlGallery.iOS
{
if (e.NewElement != null)
{
- var flowLayout = new UICollectionViewFlowLayout {
+ var flowLayout = new UICollectionViewFlowLayout
+ {
SectionInset = new UIEdgeInsets(20, 20, 20, 20),
ScrollDirection = UICollectionViewScrollDirection.Vertical,
MinimumInteritemSpacing = 5, // minimum spacing between cells 
@@ -480,7 +531,7 @@ namespace Xamarin.Forms.ControlGallery.iOS
public override void ViewDidLoad()
{
base.ViewDidLoad();
- CollectionView.RegisterClassForCell(typeof(CollectionViewCell), cellId);
+ CollectionView.RegisterClassForCell(typeof (CollectionViewCell), cellId);
}
#if __UNIFIED__
@@ -521,10 +572,7 @@ namespace Xamarin.Forms.ControlGallery.iOS
public class CollectionViewCell : UICollectionViewCell
{
- public UILabel Label
- {
- get; private set;
- }
+ public UILabel Label { get; private set; }
[Export("initWithFrame:")]
public CollectionViewCell(RectangleF frame) : base(frame)
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39987.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39987.cs
new file mode 100644
index 00000000..64ba5063
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39987.cs
@@ -0,0 +1,49 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 39987, "Bug 39987 - MapView not working correctly on iOS 9.3")]
+ public class Bugzilla39987 : TestTabbedPage // or TestMasterDetailPage, etc ...
+ {
+ protected override void Init()
+ {
+ Children.Add(new CustomMapPage(new CustomMapView(), "Teste 1"));
+ Children.Add(new CustomMapPage(new CustomMapView(), "Teste 2"));
+ Children.Add(new CustomMapPage(new CustomMapView(), "Teste 3"));
+ }
+
+ }
+
+ public class CustomMapView : View
+ {
+ public CustomMapView()
+ {
+
+ }
+
+ }
+
+ public class CustomMapPage : ContentPage
+ {
+ private CustomMapView _customMapView;
+
+
+ public CustomMapPage(CustomMapView customMapView, string title)
+ {
+ Title = title;
+ _customMapView = customMapView;
+ _customMapView.HorizontalOptions = LayoutOptions.FillAndExpand;
+ _customMapView.VerticalOptions = LayoutOptions.FillAndExpand;
+ Content = _customMapView;
+ }
+
+ }
+}
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 5eff8aef..5f0ad474 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -400,6 +400,7 @@
<DependentUpon>Bugzilla39378.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39963.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla39987.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla22229.xaml">
diff --git a/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs b/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs
index 0dbd7f9a..c9396769 100644
--- a/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs
+++ b/Xamarin.Forms.Platform.iOS/VisualElementTracker.cs
@@ -171,7 +171,7 @@ namespace Xamarin.Forms.Platform.iOS
var target = new RectangleF(x, y, width, height);
// must reset transform prior to setting frame...
caLayer.Transform = transform;
- caLayer.Frame = target;
+ uiview.Frame = target;
if (shouldRelayoutSublayers)
caLayer.LayoutSublayers();
}