Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-20178] Support Peek and Pop in Ti.UI.WebView #7600

Merged
merged 3 commits into from
Dec 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions apidoc/Titanium/UI/WebView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,24 @@ events:

properties:

- name: allowsLinkPreview
summary: |
A Boolean value that determines whether pressing on a link displays a preview of the
destination for the link.
description: |
This property is available on devices that support 3D Touch. Default value is `false`.

If you set this value to `true` for a web view, users (with devices that support 3D Touch)
can preview link destinations, and can preview detected data such as addresses, by pressing on links.
Such previews are known to users as peeks. If a user presses deeper, the preview navigates (or pops,
in user terminology) to the destination. Because pop navigation switches the user from your app to
Safari, it is opt-in, by way of this property, rather default behavior for this class.
type: Boolean
default: false
since: "6.0.0"
osver: {ios: {min: "9.0"}}
platforms: [iphone]

- name: data
summary: Web content to load.
description: |
Expand Down
1 change: 1 addition & 0 deletions iphone/Classes/TiUIWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
-(void)reload;

-(void)setHtml_:(NSString*)content withObject:(id)property;
-(void)setAllowsLinkPreview_:(id)value;

@end

Expand Down
11 changes: 11 additions & 0 deletions iphone/Classes/TiUIWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,17 @@ -(id)url
return url;
}

-(void)setAllowsLinkPreview_:(id)value
{
#if IS_XCODE_7
if ([TiUtils isIOS9OrGreater] == NO) {
return;
}
ENSURE_TYPE(value, NSNumber);
[webview setAllowsLinkPreview:[TiUtils boolValue:value]];
#endif
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return type is id but returns nothing, this will crash on device

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't crash on the iPhone 6S test device, but of course it needs to be void. Fixed.

- (void)reload
{
RELEASE_TO_NIL(lastValidLoad);
Expand Down