~jose-exposito89/ubuntuone-ios-files/social-networking

« back to all changes in this revision

Viewing changes to Dependencies/ShareKit/Classes/Example/ExampleShareLink.m

  • Committer: José Expósito
  • Date: 2012-10-23 15:22:36 UTC
  • Revision ID: jose.exposito89@gmail.com-20121023152236-f2rfafq000ex0vgz
Added support to share links in social networks

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
    //
 
2
//  ExampleShareLink.m
 
3
//  ShareKit
 
4
//
 
5
//  Created by Nathan Weiner on 6/17/10.
 
6
 
 
7
//
 
8
//  Permission is hereby granted, free of charge, to any person obtaining a copy
 
9
//  of this software and associated documentation files (the "Software"), to deal
 
10
//  in the Software without restriction, including without limitation the rights
 
11
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
12
//  copies of the Software, and to permit persons to whom the Software is
 
13
//  furnished to do so, subject to the following conditions:
 
14
//
 
15
//  The above copyright notice and this permission notice shall be included in
 
16
//  all copies or substantial portions of the Software.
 
17
//
 
18
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
19
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
20
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
21
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
22
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
23
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
24
//  THE SOFTWARE.
 
25
//
 
26
//
 
27
 
 
28
#import "ExampleShareLink.h"
 
29
#import "SHK.h"
 
30
 
 
31
@implementation ExampleShareLink
 
32
 
 
33
@synthesize webView;
 
34
 
 
35
- (void)dealloc
 
36
{
 
37
        [webView release];
 
38
        [super dealloc];
 
39
}
 
40
 
 
41
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
 
42
{
 
43
        if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
 
44
        {
 
45
                self.toolbarItems = [NSArray arrayWithObjects:
 
46
                                                                [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
 
47
                                                         [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
 
48
                                                                [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
 
49
                                                                nil
 
50
                                                        ];
 
51
        }
 
52
        
 
53
        return self;
 
54
}
 
55
 
 
56
- (void)share
 
57
{
 
58
        SHKItem *item = [SHKItem URL:webView.request.URL title:[webView pageTitle] contentType:(SHKURLContentTypeWebpage)];
 
59
 
 
60
    /* bellow are examples how to preload SHKItem with some custom sharer specific settings. You can prefill them ad hoc during each particular SHKItem createion, or set them globally in your configurator, so that every SHKItem is prefilled with the same values. More info in SHKItem.h or DefaultSHKConfigurator.m.    
 
61
    
 
62
    SHKItem *item = [SHKItem URL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=3t8MeE8Ik4Y"] title:@"Big bang" contentType:SHKURLContentTypeVideo];
 
63
    item.facebookURLSharePictureURI = @"http://www.state.gov/cms_images/india_tajmahal_2003_06_252.jpg";
 
64
    item.facebookURLShareDescription = @"description text";
 
65
    item.tags = [NSArray arrayWithObjects:@"apple inc.",@"computers",@"mac", nil];
 
66
    item.mailToRecipients = [NSArray arrayWithObjects:@"frodo@middle-earth.me", @"gandalf@middle-earth.me", nil];
 
67
    item.textMessageToRecipients = [NSArray arrayWithObjects: @"581347615", @"581344543", nil];
 
68
    */
 
69
    
 
70
        SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
 
71
    [SHK setRootViewController:self];
 
72
        [actionSheet showFromToolbar:self.navigationController.toolbar]; 
 
73
}
 
74
 
 
75
- (void)loadView 
 
76
 
77
        self.webView = [[[UIWebView alloc] initWithFrame:CGRectZero] autorelease];
 
78
        webView.delegate = self;
 
79
        webView.scalesPageToFit = YES;
 
80
        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://apple.com"]]];
 
81
                
 
82
        self.view = webView;
 
83
}
 
84
 
 
85
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
 
86
{
 
87
    return YES;
 
88
}
 
89
 
 
90
@end