Skip to content

Commit e1cc78f

Browse files
Fix Share button on iPads
1 parent b93f97b commit e1cc78f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

iloveusomuch/Base.lproj/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<rect key="frame" x="137.66666666666663" y="0.0" width="621" height="414"/>
2121
</imageView>
2222
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="YXm-la-ajX" userLabel="Contents Stack View">
23-
<rect key="frame" x="184" y="120.66666666666669" width="528" height="232.66666666666663"/>
23+
<rect key="frame" x="184" y="120.66666666666667" width="528" height="232.66666666666663"/>
2424
<subviews>
2525
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="fill" contentVerticalAlignment="fill" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MKG-jo-3nz" userLabel="Play Button">
2626
<rect key="frame" x="0.0" y="0.0" width="528" height="134.33333333333334"/>
@@ -44,7 +44,7 @@
4444
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
4545
<state key="normal" image="share"/>
4646
<connections>
47-
<action selector="share" destination="BYZ-38-t0r" eventType="touchDown" id="oei-Ah-MBF"/>
47+
<action selector="share:" destination="BYZ-38-t0r" eventType="touchDown" id="uS3-sI-gbQ"/>
4848
</connections>
4949
</button>
5050
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="fill" contentVerticalAlignment="fill" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="GOM-VT-roO" userLabel="Listen Button">

iloveusomuch/ViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111

1212
- (IBAction)play;
13-
- (IBAction)share;
13+
- (IBAction)share: (UIButton*)sender;
1414
- (IBAction)listen;
1515
- (void)didEnterBackground:(NSNotification *)notification;
1616
- (void)willEnterForeground:(NSNotification *)notification;

iloveusomuch/ViewController.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,15 @@ - (IBAction)play {
7272
[[[[UIApplication sharedApplication] windows] firstObject] setRootViewController: vc];
7373
}
7474

75-
- (IBAction)share {
75+
- (IBAction)share: (UIButton*)sender {
7676
// Opens a share screen with a link of this project
7777
NSURL *url = [NSURL URLWithString: SHARE_URL];
7878
UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:@[url] applicationActivities:nil];
79+
80+
// Required for iPads
81+
[[vc popoverPresentationController] setSourceView: (UIView*)sender];
82+
[[vc popoverPresentationController] setSourceRect: sender.frame];
83+
7984
[self presentViewController:vc animated:YES completion:nil];
8085
}
8186

0 commit comments

Comments
 (0)