Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
VLC-iOS
Commits
e09a2706
Commit
e09a2706
authored
Mar 27, 2017
by
Soomin Lee
Committed by
Jean-Baptiste Kempf
Mar 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iOS: Add collectionView landscape orientation for phones
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
7e4ae0fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
16 deletions
+31
-16
Sources/VLCLibraryViewController.m
Sources/VLCLibraryViewController.m
+28
-16
Sources/VLCMovieViewController.m
Sources/VLCMovieViewController.m
+3
-0
No files found.
Sources/VLCLibraryViewController.m
View file @
e09a2706
...
...
@@ -97,6 +97,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
-
(
void
)
loadView
{
[
self
setupContentViewWithContentInset
:
NO
];
[
self
setViewFromDeviceOrientation
];
[
self
updateViewsForCurrentDisplayMode
];
_libraryMode
=
VLCLibraryModeAllFiles
;
...
...
@@ -152,21 +153,18 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
[
contentView
addSubview
:
_collectionView
];
[
_collectionView
reloadData
];
}
if
(
setInset
)
{
CGSize
statusBarSize
=
[
UIApplication
sharedApplication
].
statusBarFrame
.
size
;
// Status bar frame doesn't change correctly on rotation
CGFloat
statusBarHeight
=
MIN
(
statusBarSize
.
height
,
statusBarSize
.
width
);
CGFloat
originY
=
self
.
navigationController
.
navigationBar
.
frame
.
size
.
height
+
statusBarHeight
;
UIScrollView
*
playlistView
=
self
.
usingTableViewToShowData
?
_tableView
:
_collectionView
;
playlistView
.
contentInset
=
UIEdgeInsetsMake
(
originY
,
0
,
0
,
0
);
}
self
.
view
=
contentView
;
}
#pragma mark -
-
(
void
)
viewWillLayoutSubviews
{
UIScrollView
*
dataView
=
self
.
usingTableViewToShowData
?
_tableView
:
_collectionView
;
[[
UIApplication
sharedApplication
]
setStatusBarHidden
:
NO
withAnimation
:
UIStatusBarAnimationNone
];
[
dataView
setContentInset
:
UIEdgeInsetsZero
];
}
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
...
...
@@ -243,6 +241,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
_searchBar
.
delegate
=
self
;
[
self
setSearchBar
:
YES
resetContent
:
YES
];
self
.
edgesForExtendedLayout
=
UIRectEdgeNone
;
@synchronized
(
self
)
{
_searchData
=
[[
NSMutableArray
alloc
]
init
];
...
...
@@ -488,10 +487,22 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
[
self
updateViewsForCurrentDisplayMode
];
}
-
(
void
)
set
SearchBar
:(
BOOL
)
enable
resetContent
:(
BOOL
)
resetContent
-
(
void
)
set
ViewFromDeviceOrientation
{
self
.
tableView
.
tableHeaderView
=
enable
?
_searchBar
:
nil
;
if
(
UI_USER_INTERFACE_IDIOM
()
==
UIUserInterfaceIdiomPhone
)
{
UIDevice
*
currentDevice
=
[
UIDevice
currentDevice
];
BOOL
isPortrait
=
UIDeviceOrientationIsPortrait
(
currentDevice
.
orientation
);
[
self
setUsingTableViewToShowData
:
isPortrait
];
}
}
-
(
void
)
setSearchBar
:(
BOOL
)
enable
resetContent
:(
BOOL
)
resetContent
{
if
(
enable
)
self
.
tableView
.
tableHeaderView
=
_searchBar
;
else
self
.
tableView
.
tableHeaderView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
.
0
f
,
0
.
0
f
,
self
.
tableView
.
bounds
.
size
.
width
,
CGFLOAT_MIN
)];
if
(
resetContent
)
{
CGPoint
contentOffset
=
self
.
tableView
.
contentOffset
;
contentOffset
.
y
+=
CGRectGetHeight
(
self
.
tableView
.
tableHeaderView
.
frame
);
...
...
@@ -846,7 +857,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
-
(
CGSize
)
collectionView
:(
UICollectionView
*
)
collectionView
layout
:(
UICollectionViewLayout
*
)
collectionViewLayout
sizeForItemAtIndexPath
:(
NSIndexPath
*
)
indexPath
{
const
CGFloat
maxCellWidth
=
300
.
0
;
const
CGFloat
maxCellWidth
=
[
UIScreen
mainScreen
].
bounds
.
size
.
width
/
3
;
const
CGFloat
aspectRatio
=
9
.
0
/
16
.
0
;
CGRect
windowFrame
=
[
UIApplication
sharedApplication
].
keyWindow
.
frame
;
...
...
@@ -854,19 +865,19 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
int
numberOfCellsPerRow
=
ceil
(
windowWidth
/
maxCellWidth
);
CGFloat
cellWidth
=
windowWidth
/
numberOfCellsPerRow
;
cellWidth
-=
5
;
return
CGSizeMake
(
cellWidth
,
cellWidth
*
aspectRatio
);
}
-
(
UIEdgeInsets
)
collectionView
:(
UICollectionView
*
)
collectionView
layout
:(
UICollectionViewLayout
*
)
collectionViewLayout
insetForSectionAtIndex
:(
NSInteger
)
section
{
return
UIEdgeInsets
Zero
;
return
UIEdgeInsets
Make
(
5
,
5
,
5
,
5
)
;
}
-
(
CGFloat
)
collectionView
:(
UICollectionView
*
)
collectionView
layout
:(
UICollectionViewLayout
*
)
collectionViewLayout
minimumLineSpacingForSectionAtIndex
:(
NSInteger
)
section
{
return
0
.
;
return
2
.
5
;
}
-
(
CGFloat
)
collectionView
:(
UICollectionView
*
)
collectionView
layout
:(
UICollectionViewLayout
*
)
collectionViewLayout
minimumInteritemSpacingForSectionAtIndex
:(
NSInteger
)
section
...
...
@@ -1662,6 +1673,7 @@ static NSString *kUsingTableViewToShowData = @"UsingTableViewToShowData";
{
[
super
willRotateToInterfaceOrientation
:
toInterfaceOrientation
duration
:
duration
];
[
self
setViewFromDeviceOrientation
];
if
(
self
.
usingTableViewToShowData
)
{
NSArray
*
visibleCells
=
[
self
.
tableView
visibleCells
];
NSUInteger
cellCount
=
visibleCells
.
count
;
...
...
Sources/VLCMovieViewController.m
View file @
e09a2706
...
...
@@ -34,6 +34,7 @@
#import "VLCStatusLabel.h"
#import "VLCMovieViewControlPanelViewController.h"
#import "VLCSlider.h"
#import "VLCLibraryViewController.h"
#define FORWARD_SWIPE_DURATION 30
#define BACKWARD_SWIPE_DURATION 10
...
...
@@ -1592,6 +1593,8 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
[
super
willRotateToInterfaceOrientation
:
toInterfaceOrientation
duration
:
duration
];
if
(
UI_USER_INTERFACE_IDIOM
()
==
UIUserInterfaceIdiomPhone
)
{
[[(
VLCAppDelegate
*
)[
UIApplication
sharedApplication
].
delegate
libraryViewController
]
willRotateToInterfaceOrientation
:
toInterfaceOrientation
duration
:
duration
];
if
(
self
.
artworkImageView
.
image
)
self
.
trackNameLabel
.
hidden
=
UIInterfaceOrientationIsLandscape
(
toInterfaceOrientation
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment