Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create a UIWebClip
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