Created
May 21, 2014 08:02
-
-
Save JatWaston/312d58995f323d695dfb to your computer and use it in GitHub Desktop.
Create a UIWebClip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIWebClip *clip = [UIWebClip webClipWithIdentifier:nil]; | |
//UIWebClip *clip = [UIWebClip webClipWithURL:[webpage.request.mainDocumentURL absoluteString]]; | |
[clip retain]; | |
[clip setPageURL:webpage.request.mainDocumentURL]; | |
[clip setTitle:[webpage stringByEvaluatingJavaScriptFromString:@"document.title"]]; | |
UIWebDocumentView *docView = nil; | |
UIScrollView *webpagescroller = [[webpage subviews] objectAtIndex:0]; | |
for (UIView* aView in [webpagescroller subviews]){ | |
if ([aView isKindOfClass:[NSClassFromString(@"UIWebBrowserView") class]]){ | |
docView = (UIWebDocumentView *)aView; | |
} | |
} | |
[clip setIcons:[UIWebClip webClipIconsForWebDocumentView:docView]]; | |
[clip setStatusBarStyle:[UIWebClip webClipStatusBarStyleForWebDocumentView:docView]]; | |
[clip setFullScreen:[UIWebClip webClipFullScreenValueForWebDocumentView:docView]]; | |
[clip setClassicMode:[UIWebClip webClipClassicModeValueForWebDocumentView:docView]]; | |
[clip setScale:[webpagescroller zoomScale]]; | |
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); | |
NSString *uuidstr = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid); | |
[clip setIdentifier:uuidstr]; | |
UIApplication *app = [UIApplication sharedApplication]; | |
[app addWebClipToHomeScreen:[clip identifier]]; | |
[clip release]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment