Skip to content

Commit

Permalink
iOS: Fixed several rotation issues on iPad in ResumePlaybackViewContr…
Browse files Browse the repository at this point in the history
…oller and PlayerViewController.
  • Loading branch information
ycastonguay committed Nov 19, 2013
1 parent 0bd4013 commit 61e0dc1
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 46 deletions.
12 changes: 7 additions & 5 deletions MPfm/MPfm.iOS/Classes/Controllers/PlayerViewController.cs
Expand Up @@ -88,11 +88,11 @@ public override void ViewDidLoad()
sliderPosition.SetThumbImage(UIImage.FromBundle("Images/Sliders/thumb"), UIControlState.Normal);

// Reduce the song position slider size for iPhone
if(UserInterfaceIdiomIsPhone)
{
sliderPosition.Transform = CGAffineTransform.MakeScale(0.7f, 0.7f);
sliderPosition.Frame = new RectangleF(70, sliderPosition.Frame.Y - 10, UIScreen.MainScreen.Bounds.Width - 140, sliderPosition.Frame.Height);
}
sliderPosition.Transform = CGAffineTransform.MakeScale(0.7f, 0.7f);
// if (UserInterfaceIdiomIsPhone)
// {
// sliderPosition.Frame = new RectangleF(70, sliderPosition.Frame.Y - 10, UIScreen.MainScreen.Bounds.Width - 140, sliderPosition.Frame.Height);
// }

// Setup scroll view and page control
scrollView.WeakDelegate = this;
Expand Down Expand Up @@ -227,6 +227,8 @@ public override void ViewDidLayoutSubviews()

scrollView.ContentSize = new SizeF(3 * scrollView.Frame.Width, scrollView.Frame.Height);
}

sliderPosition.Frame = new RectangleF(70, sliderPosition.Frame.Y, View.Frame.Width - 140, sliderPosition.Frame.Height);
}

private void HandleScrollViewSwipeDown(UISwipeGestureRecognizer gestureRecognizer)
Expand Down
Expand Up @@ -51,6 +51,7 @@ public override void ViewDidLoad()
tableView.WeakDataSource = this;
tableView.WeakDelegate = this;

View.BackgroundColor = GlobalTheme.BackgroundColor;;
viewLoading.BackgroundColor = GlobalTheme.BackgroundColor;
viewTable.BackgroundColor = GlobalTheme.BackgroundColor;
viewAppNotLinked.BackgroundColor = GlobalTheme.BackgroundColor;
Expand All @@ -59,8 +60,6 @@ public override void ViewDidLoad()
viewAppNotLinked.Alpha = 0;

activityIndicator.StartAnimating();
View.BackgroundColor = GlobalTheme.BackgroundColor;
viewAppNotLinked.BackgroundColor = GlobalTheme.BackgroundColor;
btnOpenCloudPreferences.SetImage(UIImage.FromBundle("Images/Buttons/cloud"));

base.ViewDidLoad();
Expand Down
35 changes: 24 additions & 11 deletions MPfm/MPfm.iOS/Classes/Controls/MPfmNavigationController.cs
Expand Up @@ -177,12 +177,11 @@ public override void ViewDidLayoutSubviews()
base.ViewDidLayoutSubviews();

var screenSize = UIKitHelper.GetDeviceSize();
//_lblTitle.Frame = new RectangleF(78, 4, screenSize.Width - 156, 20);
//_lblTitle.Frame = new RectangleF(78, 0, screenSize.Width - 156, 44);
_btnBack.Frame = new RectangleF(0, 0, 70, 44);
_btnEffects.Frame = new RectangleF(screenSize.Width - 70, 0, 70, 44);
_btnNowPlaying.Frame = new RectangleF(screenSize.Width - 70, 0, 70, 44);
//_imageViewIcon.Frame = new RectangleF(78, 14, 16, 16);
_btnPlaylist.Frame = new RectangleF((screenSize.Width - 80) / 2, 0, 80, 44);
SetTitleFrame();
}

protected virtual void OnViewDismissed(EventArgs e)
Expand Down Expand Up @@ -334,15 +333,8 @@ public void SetTitle(string title, string iconName)
}
else
{
UIGraphics.BeginImageContextWithOptions(View.Frame.Size, true, 0);
var context = UIGraphics.GetCurrentContext();
float width = CoreGraphicsHelper.MeasureStringWidth(context, title, _lblTitle.Font.Name, _lblTitle.Font.PointSize);
UIGraphics.EndImageContext();

float titleWidth = width > screenSize.Width - 156 - 24 ? screenSize.Width - 156 - 24 : width;
_lblTitle.Frame = new RectangleF((screenSize.Width - titleWidth + 24) / 2, 0, titleWidth, 44);
_imageViewIcon.Image = UIImage.FromBundle(string.Format("Images/Nav/{0}", iconName));
_imageViewIcon.Frame = new RectangleF(((screenSize.Width - titleWidth + 24) / 2) - 24, 14, 16, 16);
SetTitleFrame();
}

UIView.Animate(0.2f, delegate() {
Expand All @@ -355,5 +347,26 @@ public void SetBackButtonVisible(bool visible)
{
_btnBack.Hidden = !visible;
}

private void SetTitleFrame()
{
var screenSize = UIKitHelper.GetDeviceSize();

if (_imageViewIcon.Image == null)
{
_lblTitle.Frame = new RectangleF(78, 0, screenSize.Width - 156, 44);
}
else
{
UIGraphics.BeginImageContextWithOptions(View.Frame.Size, true, 0);
var context = UIGraphics.GetCurrentContext();
float width = CoreGraphicsHelper.MeasureStringWidth(context, _lblTitle.Text, _lblTitle.Font.Name, _lblTitle.Font.PointSize);
UIGraphics.EndImageContext();

float titleWidth = width > screenSize.Width - 156 - 24 ? screenSize.Width - 156 - 24 : width;
_lblTitle.Frame = new RectangleF((screenSize.Width - titleWidth + 24) / 2, 0, titleWidth, 44);
_imageViewIcon.Frame = new RectangleF(((screenSize.Width - titleWidth + 24) / 2) - 24, 14, 16, 16);
}
}
}
}
Expand Up @@ -161,6 +161,8 @@ public void Initialize()

public override void LayoutSubviews()
{
base.LayoutSubviews();

BackgroundView.Frame = new RectangleF(0, 0, Frame.Width, Frame.Height);
SelectedBackgroundView.Frame = new RectangleF(0, 0, Frame.Width, Frame.Height);

Expand All @@ -172,7 +174,7 @@ public override void LayoutSubviews()
LabelLastUpdated.Frame = new RectangleF(12, 106, Frame.Width - 24, 20);
ImageIcon.Frame = new RectangleF(12, 12, 30, 30);
ImageAlbum.Frame = new RectangleF(12, 50, 54, 54);
ImageChevron.Frame = new RectangleF(UIScreen.MainScreen.Bounds.Width - 22, 43, 22, 44);
ImageChevron.Frame = new RectangleF(Frame.Width - 22, 43, 22, 44);
ViewOverlay.Frame = new RectangleF(0, 0, Frame.Width, Frame.Height);
LabelCellDisabled.Frame = new RectangleF(12, 0, Frame.Width - 24, Frame.Height);
}
Expand Down
44 changes: 27 additions & 17 deletions MPfm/MPfm.iOS/XIB/iPad/PlayerViewController_iPad.xib
Expand Up @@ -32,19 +32,19 @@
<rect key="frame" x="0.0" y="64" width="768" height="960"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4">
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4">
<rect key="frame" x="0.0" y="150" width="768" height="733"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="12">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="12">
<rect key="frame" x="0.0" y="0.0" width="768" height="733"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" pagingEnabled="YES" translatesAutoresizingMaskIntoConstraints="NO" id="13">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" pagingEnabled="YES" translatesAutoresizingMaskIntoConstraints="NO" id="13">
<rect key="frame" x="0.0" y="0.0" width="768" height="709"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</scrollView>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="17">
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="17">
<rect key="frame" x="0.0" y="709" width="768" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
Expand All @@ -58,13 +58,18 @@
</subviews>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="12" firstAttribute="leading" secondItem="4" secondAttribute="leading" id="Ksb-xB-Cdj"/>
<constraint firstItem="13" firstAttribute="leading" secondItem="4" secondAttribute="leading" id="VUu-li-PNe"/>
<constraint firstAttribute="trailing" secondItem="12" secondAttribute="trailing" id="pcP-co-hXx"/>
<constraint firstAttribute="trailing" secondItem="13" secondAttribute="trailing" id="sq2-mW-7qN"/>
<constraint firstAttribute="bottom" secondItem="17" secondAttribute="bottom" id="7Aa-dz-IDg"/>
<constraint firstItem="13" firstAttribute="leading" secondItem="4" secondAttribute="leading" id="ERq-Dx-1z4"/>
<constraint firstItem="12" firstAttribute="leading" secondItem="4" secondAttribute="leading" id="OMv-b3-ttb"/>
<constraint firstAttribute="bottom" secondItem="13" secondAttribute="bottom" constant="24" id="OXC-Mi-VeV"/>
<constraint firstAttribute="trailing" secondItem="12" secondAttribute="trailing" id="Q3q-dA-Lcw"/>
<constraint firstAttribute="bottom" secondItem="12" secondAttribute="bottom" id="Q9c-h5-daJ"/>
<constraint firstAttribute="trailing" secondItem="13" secondAttribute="trailing" id="QPO-r2-0x4"/>
<constraint firstItem="13" firstAttribute="top" secondItem="4" secondAttribute="top" id="iwt-Yh-Xak"/>
<constraint firstItem="12" firstAttribute="top" secondItem="4" secondAttribute="top" id="taX-SA-7Lx"/>
</constraints>
</view>
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5">
<view contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="5" userLabel="Position View">
<rect key="frame" x="0.0" y="0.0" width="768" height="28"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
Expand Down Expand Up @@ -93,7 +98,7 @@
<rect key="frame" x="76" y="0.0" width="610" height="23"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</slider>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" fixedFrame="YES" text="00:00.000" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsLetterSpacingToFitWidth="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="10">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" ambiguous="YES" misplaced="YES" text="00:00.000" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsLetterSpacingToFitWidth="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="10">
<rect key="frame" x="692" y="1" width="66" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="HelveticaNeue" family="Helvetica Neue" pointSize="13"/>
Expand All @@ -102,8 +107,11 @@
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.40000000000000002" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="10" secondAttribute="trailing" constant="10" id="ag4-xH-LrV"/>
</constraints>
</view>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6" customClass="MPfmWaveFormScrollView">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6" userLabel="WaveFormScrollView" customClass="MPfmWaveFormScrollView">
<rect key="frame" x="0.0" y="24" width="768" height="128"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</scrollView>
Expand Down Expand Up @@ -197,16 +205,18 @@
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="4" firstAttribute="top" secondItem="2" secondAttribute="top" constant="150" id="21Z-yX-Xnr"/>
<constraint firstAttribute="centerX" secondItem="kLq-Aa-pB9" secondAttribute="centerX" id="5Lm-db-aBf"/>
<constraint firstItem="4" firstAttribute="leading" secondItem="2" secondAttribute="leading" id="CyQ-a5-BdO"/>
<constraint firstAttribute="trailing" secondItem="4" secondAttribute="trailing" id="Eoz-LK-lbo"/>
<constraint firstAttribute="trailing" secondItem="4" secondAttribute="trailing" id="J5e-Wj-tGL"/>
<constraint firstItem="4" firstAttribute="top" secondItem="5" secondAttribute="bottom" constant="122" id="JBS-pd-1yp"/>
<constraint firstAttribute="bottom" secondItem="4" secondAttribute="bottom" constant="77" id="EaN-fi-nUQ"/>
<constraint firstAttribute="trailing" secondItem="6" secondAttribute="trailing" id="NE8-B9-P36"/>
<constraint firstItem="5" firstAttribute="leading" secondItem="2" secondAttribute="leading" id="QPh-4B-k0D"/>
<constraint firstAttribute="bottom" secondItem="4" secondAttribute="bottom" constant="77" id="Ulq-HF-pim"/>
<constraint firstItem="6" firstAttribute="leading" secondItem="2" secondAttribute="leading" id="RbY-yA-JWl"/>
<constraint firstAttribute="bottom" secondItem="kLq-Aa-pB9" secondAttribute="bottom" id="XNa-pd-GCF"/>
<constraint firstAttribute="trailing" secondItem="5" secondAttribute="trailing" id="Xbp-YS-ZnO"/>
<constraint firstItem="4" firstAttribute="leading" secondItem="2" secondAttribute="leading" id="jzt-OF-Z5i"/>
<constraint firstItem="6" firstAttribute="top" secondItem="2" secondAttribute="top" constant="24" id="ZzY-EU-X30"/>
<constraint firstItem="kLq-Aa-pB9" firstAttribute="top" secondItem="4" secondAttribute="bottom" constant="-1" id="avd-zp-IfI"/>
<constraint firstAttribute="trailing" secondItem="4" secondAttribute="trailing" id="krf-lc-weg"/>
<constraint firstItem="4" firstAttribute="leading" secondItem="2" secondAttribute="leading" id="tKk-wh-2Re"/>
</constraints>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics" statusBarStyle="blackOpaque"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
Expand Down

0 comments on commit 61e0dc1

Please sign in to comment.