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

« back to all changes in this revision

Viewing changes to Dependencies/ShareKit/Classes/Example/RootViewController.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
//  RootViewController.m
 
3
//  ShareKit
 
4
//
 
5
//  Created by Nathan Weiner on 6/4/10.
 
6
//  Copyright Idea Shower, LLC 2010. All rights reserved.
 
7
//
 
8
 
 
9
#import "RootViewController.h"
 
10
#import "ExampleShareLink.h"
 
11
#import "ExampleShareImage.h"
 
12
#import "ExampleShareText.h"
 
13
#import "ExampleShareFile.h"
 
14
#import "SHK.h"
 
15
 
 
16
@implementation RootViewController
 
17
 
 
18
- (void)loadView
 
19
{
 
20
        [super loadView];
 
21
        
 
22
        self.toolbarItems = [NSArray arrayWithObjects:
 
23
                                                 [[[UIBarButtonItem alloc] initWithTitle:SHKLocalizedString(@"Logout") style:UIBarButtonItemStyleBordered target:self action:@selector(logout)] autorelease],
 
24
                                                 nil
 
25
                                                 ];     
 
26
}
 
27
 
 
28
#pragma mark -
 
29
#pragma mark Table view data source
 
30
 
 
31
 
 
32
// Customize the number of sections in the table view.
 
33
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
 
34
    return 1;
 
35
}
 
36
 
 
37
 
 
38
// Customize the number of rows in the table view.
 
39
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
 
40
{
 
41
    return 4;//5;
 
42
}
 
43
 
 
44
 
 
45
// Customize the appearance of table view cells.
 
46
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
 
47
{    
 
48
    static NSString *CellIdentifier = @"Cell";
 
49
    
 
50
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
 
51
    if (cell == nil) {
 
52
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
 
53
    }
 
54
    
 
55
        switch (indexPath.row) 
 
56
        {
 
57
                case 0:
 
58
                        cell.textLabel.text = SHKLocalizedString(@"Sharing a Link");
 
59
                        break;
 
60
                        
 
61
                case 1:
 
62
                        cell.textLabel.text = SHKLocalizedString(@"Sharing an Image");
 
63
                        break;
 
64
                        
 
65
                case 2:
 
66
                        cell.textLabel.text = SHKLocalizedString(@"Sharing Text");
 
67
                        break;
 
68
                        
 
69
                case 3:
 
70
                        cell.textLabel.text = SHKLocalizedString(@"Sharing a File");
 
71
                        break;
 
72
                        
 
73
                //case 4:
 
74
                //      cell.textLabel.text = @"Logout of All Services";
 
75
                //      break;
 
76
        }
 
77
 
 
78
    return cell;
 
79
}
 
80
 
 
81
 
 
82
#pragma mark -
 
83
#pragma mark Table view delegate
 
84
 
 
85
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
 
86
{
 
87
        switch (indexPath.row) 
 
88
        {
 
89
                case 0:
 
90
                        [self.navigationController pushViewController:[[[ExampleShareLink alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
 
91
                        break;
 
92
                        
 
93
                case 1:
 
94
                        
 
95
                        [self.navigationController pushViewController:[[[ExampleShareImage alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
 
96
                        break;
 
97
                        
 
98
                case 2:
 
99
                        [self.navigationController pushViewController:[[[ExampleShareText alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
 
100
                        break;
 
101
                        
 
102
                case 3:
 
103
                        [self.navigationController pushViewController:[[[ExampleShareFile alloc] initWithNibName:nil bundle:nil] autorelease] animated:YES];
 
104
                        break;
 
105
                        
 
106
                //case 4:
 
107
                //      [SHK logoutOfAll];
 
108
                //      break;                  
 
109
                        
 
110
        }
 
111
}
 
112
 
 
113
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
 
114
{
 
115
    return YES;
 
116
}
 
117
 
 
118
 
 
119
#pragma mark -
 
120
 
 
121
- (void)logout
 
122
{
 
123
        [[[[UIAlertView alloc] initWithTitle:SHKLocalizedString(@"Logout")
 
124
                                                                 message:SHKLocalizedString(@"Are you sure you want to logout of all share services?")
 
125
                                                                delegate:self
 
126
                                           cancelButtonTitle:SHKLocalizedString(@"Cancel")
 
127
                                           otherButtonTitles:SHKLocalizedString(@"Logout"),nil] autorelease] show];
 
128
        
 
129
}
 
130
 
 
131
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
 
132
{
 
133
        if (buttonIndex == alertView.firstOtherButtonIndex)
 
134
                [SHK logoutOfAll];
 
135
}
 
136
 
 
137
 
 
138
@end
 
139