@@ -1100,7 +1100,16 @@ - (void)updateNavigation {
1100
1100
// Buttons
1101
1101
_previousButton.enabled = (_currentPageIndex > 0 );
1102
1102
_nextButton.enabled = (_currentPageIndex < numberOfPhotos - 1 );
1103
- _actionButton.enabled = [[self photoAtIndex: _currentPageIndex] underlyingImage ] != nil ;
1103
+
1104
+ // Disable action button if there is no image or it's a video
1105
+ MWPhoto *photo = [self photoAtIndex: _currentPageIndex];
1106
+ if ([photo underlyingImage ] == nil || ([photo respondsToSelector: @selector (isVideo )] && photo.isVideo )) {
1107
+ _actionButton.enabled = NO ;
1108
+ _actionButton.tintColor = [UIColor clearColor ]; // Tint to hide button
1109
+ } else {
1110
+ _actionButton.enabled = YES ;
1111
+ _actionButton.tintColor = nil ;
1112
+ }
1104
1113
1105
1114
}
1106
1115
@@ -1529,61 +1538,55 @@ - (void)doneButtonPressed:(id)sender {
1529
1538
#pragma mark - Actions
1530
1539
1531
1540
- (void )actionButtonPressed : (id )sender {
1532
- if (_actionsSheet) {
1533
-
1534
- // Dismiss
1535
- [_actionsSheet dismissWithClickedButtonIndex: _actionsSheet.cancelButtonIndex animated: YES ];
1536
-
1537
- } else {
1541
+
1542
+ // Only react when image has loaded
1543
+ id <MWPhoto> photo = [self photoAtIndex: _currentPageIndex];
1544
+ if ([self numberOfPhotos ] > 0 && [photo underlyingImage ]) {
1538
1545
1539
- // Only react when image has loaded
1540
- id <MWPhoto> photo = [self photoAtIndex: _currentPageIndex];
1541
- if ([self numberOfPhotos ] > 0 && [photo underlyingImage ]) {
1546
+ // If they have defined a delegate method then just message them
1547
+ if ([self .delegate respondsToSelector: @selector (photoBrowser:actionButtonPressedForPhotoAtIndex: )]) {
1542
1548
1543
- // If they have defined a delegate method then just message them
1544
- if ([self .delegate respondsToSelector: @selector (photoBrowser:actionButtonPressedForPhotoAtIndex: )]) {
1545
-
1546
- // Let delegate handle things
1547
- [self .delegate photoBrowser: self actionButtonPressedForPhotoAtIndex: _currentPageIndex];
1548
-
1549
- } else {
1550
-
1551
- // Show activity view controller
1552
- NSMutableArray *items = [NSMutableArray arrayWithObject: [photo underlyingImage ]];
1553
- if (photo.caption ) {
1554
- [items addObject: photo.caption];
1555
- }
1556
- self.activityViewController = [[UIActivityViewController alloc ] initWithActivityItems: items applicationActivities: nil ];
1557
-
1558
- // Show loading spinner after a couple of seconds
1559
- double delayInSeconds = 2.0 ;
1560
- dispatch_time_t popTime = dispatch_time (DISPATCH_TIME_NOW, (int64_t )(delayInSeconds * NSEC_PER_SEC));
1561
- dispatch_after (popTime, dispatch_get_main_queue (), ^(void ){
1562
- if (self.activityViewController ) {
1563
- [self showProgressHUDWithMessage: nil ];
1564
- }
1565
- });
1566
-
1567
- // Show
1568
- typeof (self) __weak weakSelf = self;
1569
- [self .activityViewController setCompletionHandler: ^(NSString *activityType, BOOL completed) {
1570
- weakSelf.activityViewController = nil ;
1571
- [weakSelf hideControlsAfterDelay ];
1572
- [weakSelf hideProgressHUD: YES ];
1573
- }];
1574
- // iOS 8 - Set the Anchor Point for the popover
1575
- if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO (@" 8" )) {
1576
- self.activityViewController .popoverPresentationController .barButtonItem = _actionButton;
1577
- }
1578
- [self presentViewController: self .activityViewController animated: YES completion: nil ];
1579
-
1549
+ // Let delegate handle things
1550
+ [self .delegate photoBrowser: self actionButtonPressedForPhotoAtIndex: _currentPageIndex];
1551
+
1552
+ } else {
1553
+
1554
+ // Show activity view controller
1555
+ NSMutableArray *items = [NSMutableArray arrayWithObject: [photo underlyingImage ]];
1556
+ if (photo.caption ) {
1557
+ [items addObject: photo.caption];
1580
1558
}
1559
+ self.activityViewController = [[UIActivityViewController alloc ] initWithActivityItems: items applicationActivities: nil ];
1581
1560
1582
- // Keep controls hidden
1583
- [self setControlsHidden: NO animated: YES permanent: YES ];
1561
+ // Show loading spinner after a couple of seconds
1562
+ double delayInSeconds = 2.0 ;
1563
+ dispatch_time_t popTime = dispatch_time (DISPATCH_TIME_NOW, (int64_t )(delayInSeconds * NSEC_PER_SEC));
1564
+ dispatch_after (popTime, dispatch_get_main_queue (), ^(void ){
1565
+ if (self.activityViewController ) {
1566
+ [self showProgressHUDWithMessage: nil ];
1567
+ }
1568
+ });
1569
+
1570
+ // Show
1571
+ typeof (self) __weak weakSelf = self;
1572
+ [self .activityViewController setCompletionHandler: ^(NSString *activityType, BOOL completed) {
1573
+ weakSelf.activityViewController = nil ;
1574
+ [weakSelf hideControlsAfterDelay ];
1575
+ [weakSelf hideProgressHUD: YES ];
1576
+ }];
1577
+ // iOS 8 - Set the Anchor Point for the popover
1578
+ if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO (@" 8" )) {
1579
+ self.activityViewController .popoverPresentationController .barButtonItem = _actionButton;
1580
+ }
1581
+ [self presentViewController: self .activityViewController animated: YES completion: nil ];
1584
1582
1585
1583
}
1584
+
1585
+ // Keep controls hidden
1586
+ [self setControlsHidden: NO animated: YES permanent: YES ];
1587
+
1586
1588
}
1589
+
1587
1590
}
1588
1591
1589
1592
#pragma mark - Action Progress
0 commit comments