mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-15 21:21:45 +00:00
Merge pull request #429 from MichaelMKenny/ipad-alertcontroller-crash-fix
Fixed crash on iPad due to missing up UIAlertController popoverPresentation.
This commit is contained in:
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
@protocol AppCallback <NSObject>
|
@protocol AppCallback <NSObject>
|
||||||
|
|
||||||
- (void) appClicked:(TemporaryApp*) app;
|
- (void) appClicked:(TemporaryApp*)app view:(UIView*)view;
|
||||||
- (void) appLongClicked:(TemporaryApp*) app;
|
- (void) appLongClicked:(TemporaryApp*)app view:(UIView*)view;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ static UIImage* noImage;
|
|||||||
[self addGestureRecognizer:longPressRecognizer];
|
[self addGestureRecognizer:longPressRecognizer];
|
||||||
|
|
||||||
if (@available(iOS 9.0, tvOS 9.0, *)) {
|
if (@available(iOS 9.0, tvOS 9.0, *)) {
|
||||||
[self addTarget:self action:@selector(appClicked) forControlEvents:UIControlEventPrimaryActionTriggered];
|
[self addTarget:self action:@selector(appClicked:) forControlEvents:UIControlEventPrimaryActionTriggered];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[self addTarget:self action:@selector(appClicked) forControlEvents:UIControlEventTouchUpInside];
|
[self addTarget:self action:@selector(appClicked:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self addTarget:self action:@selector(buttonSelected:) forControlEvents:UIControlEventTouchDown];
|
[self addTarget:self action:@selector(buttonSelected:) forControlEvents:UIControlEventTouchDown];
|
||||||
@@ -79,13 +79,13 @@ static UIImage* noImage;
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) appClicked {
|
- (void) appClicked:(UIView *)view {
|
||||||
[_callback appClicked:_app];
|
[_callback appClicked:_app view:view];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) appLongClicked:(UILongPressGestureRecognizer*)gesture {
|
- (void) appLongClicked:(UILongPressGestureRecognizer*)gesture {
|
||||||
if (gesture.state == UIGestureRecognizerStateBegan) {
|
if (gesture.state == UIGestureRecognizerStateBegan) {
|
||||||
[_callback appLongClicked:_app];
|
[_callback appLongClicked:_app view:self];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -669,7 +669,7 @@ static NSMutableSet* hostList;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) appLongClicked:(TemporaryApp*) app {
|
- (void)appLongClicked:(TemporaryApp *)app view:(UIView *)view {
|
||||||
Log(LOG_D, @"Long clicked app: %@", app.name);
|
Log(LOG_D, @"Long clicked app: %@", app.name);
|
||||||
|
|
||||||
[_appManager stopRetrieving];
|
[_appManager stopRetrieving];
|
||||||
@@ -795,10 +795,15 @@ static NSMutableSet* hostList;
|
|||||||
}
|
}
|
||||||
|
|
||||||
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
|
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
|
||||||
|
|
||||||
|
// these two lines are required for iPad support of UIAlertSheet
|
||||||
|
alertController.popoverPresentationController.sourceView = view;
|
||||||
|
|
||||||
|
alertController.popoverPresentationController.sourceRect = CGRectMake(view.bounds.size.width / 2.0, view.bounds.size.height / 2.0, 1.0, 1.0); // center of the view
|
||||||
[[self activeViewController] presentViewController:alertController animated:YES completion:nil];
|
[[self activeViewController] presentViewController:alertController animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) appClicked:(TemporaryApp *)app {
|
- (void) appClicked:(TemporaryApp *)app view:(UIView *)view {
|
||||||
Log(LOG_D, @"Clicked app: %@", app.name);
|
Log(LOG_D, @"Clicked app: %@", app.name);
|
||||||
|
|
||||||
[_appManager stopRetrieving];
|
[_appManager stopRetrieving];
|
||||||
@@ -814,7 +819,7 @@ static NSMutableSet* hostList;
|
|||||||
|
|
||||||
if ([self findRunningApp:app.host]) {
|
if ([self findRunningApp:app.host]) {
|
||||||
// If there's a running app, display a menu
|
// If there's a running app, display a menu
|
||||||
[self appLongClicked:app];
|
[self appLongClicked:app view:view];
|
||||||
} else {
|
} else {
|
||||||
[self prepareToStreamApp:app];
|
[self prepareToStreamApp:app];
|
||||||
[self performSegueWithIdentifier:@"createStreamFrame" sender:nil];
|
[self performSegueWithIdentifier:@"createStreamFrame" sender:nil];
|
||||||
@@ -843,7 +848,7 @@ static NSMutableSet* hostList;
|
|||||||
|
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
[self appClicked:_sortedAppList[indexPath.row]];
|
[self appClicked:_sortedAppList[indexPath.row] view:nil];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user