Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
封装为静态库,支持iOS6
  • Loading branch information
JimLiu committed Sep 18, 2012
1 parent 815d480 commit 522a037
Show file tree
Hide file tree
Showing 172 changed files with 28,894 additions and 3 deletions.
12 changes: 9 additions & 3 deletions README.md
@@ -1,4 +1,10 @@
# WeiboSDKExample #
新浪微博SDK示例,基于v2版API接口,对认证和请求进行了封装,包含最新微博列表、多帐号管理、发布文字微博、发布图片微博等功能示例。
# WeiboSDK #
新浪微博SDK,基于v2版API接口,对认证和请求进行了封装,

详情请见:[WeiboSDKExample](https://github.com/JimLiu/WeiboSDK/tree/master/WeiboSDKExample "新浪微博SDK示例")
## sample ##
SDK应用示例(静态库引用),包含最新微博列表、多帐号管理、发布文字微博、发布图片微博等功能示例。
详情请见:[sample](https://github.com/JimLiu/WeiboSDK/tree/master/sample "新浪微博SDK示例")

## sample_nolib ##
SDK应用示例(非静态库引用,代码引用),包含最新微博列表、多帐号管理、发布文字微博、发布图片微博等功能示例。
详情请见:[sample](https://github.com/JimLiu/WeiboSDK/tree/master/sample_nolib "新浪微博SDK示例")
16 changes: 16 additions & 0 deletions Sample/Controllers/AccountsViewController.h
@@ -0,0 +1,16 @@
//
// AccountsViewController.h
// ZhiWeiboPhone
//
// Created by junmin liu on 12-8-20.
// Copyright (c) 2012年 idfsoft. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "WeiboSDK/WeiboSDK.h"

@interface AccountsViewController : UITableViewController<WeiboSignInDelegate> {
WeiboSignIn *_weiboSignIn;
}

@end
195 changes: 195 additions & 0 deletions Sample/Controllers/AccountsViewController.m
@@ -0,0 +1,195 @@
//
// AccountsViewController.m
// ZhiWeiboPhone
//
// Created by junmin liu on 12-8-20.
// Copyright (c) 2012年 idfsoft. All rights reserved.
//

#import "AccountsViewController.h"

@interface AccountsViewController ()

@end

@implementation AccountsViewController

- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {

}
return self;
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
UIBarButtonItem *closeButton = [[[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(close:)] autorelease];
self.navigationItem.leftBarButtonItem = closeButton;

UIBarButtonItem *addButton = [[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)] autorelease];
self.navigationItem.rightBarButtonItem = addButton;

self.title = @"Accounts";

_weiboSignIn = [[WeiboSignIn alloc] init];
_weiboSignIn.delegate = self;
}
return self;
}

- (void)dealloc {
[_weiboSignIn release];
[super dealloc];
}

- (IBAction)close:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}

- (IBAction)add:(id)sender {
[_weiboSignIn signInOnViewController:self];
}

- (void)finishedWithAuth:(WeiboAuthentication *)auth error:(NSError *)error {
if (error) {
NSLog(@"failed to auth: %@", error);
}
else {
NSLog(@"Success to auth: %@", auth.userId);
[[WeiboAccounts shared]addAccountWithAuthentication:auth];
}
[self.tableView reloadData];
}

- (void)viewDidLoad
{
[super viewDidLoad];

NSArray* toolbarItems = [NSArray arrayWithObjects:
self.editButtonItem,
nil];
self.toolbarItems = toolbarItems;
self.navigationController.toolbarHidden = NO;

}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[WeiboAccounts shared]accounts].count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"WeiboAccountCell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (!cell) {
cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
}
WeiboAccount *account = [[[WeiboAccounts shared]accounts] objectAtIndex:indexPath.row];
NSString *name = account.screenName;
if (!name) {
name = account.userId;

UserQuery *query = [UserQuery query];
query.completionBlock = ^(WeiboRequest *request, User *user, NSError *error) {
if (error) {
//
NSLog(@"UserQuery error: %@", error);
}
else {
account.screenName = user.screenName;
account.profileImageUrl = user.profileLargeImageUrl;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
(unsigned long)NULL), ^(void) {
[[WeiboAccounts shared]addAccount:account];
});
[self.tableView reloadData];
}
};
[query queryWithUserId:[account.userId longLongValue]];
}
cell.textLabel.text = name;
cell.accessoryType = account.selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;

return cell;
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/


// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
WeiboAccount *account = [[[WeiboAccounts shared]accounts] objectAtIndex:indexPath.row];
[[WeiboAccounts shared] removeWeiboAccount:account];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}


/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/

#pragma mark - Table view delegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 52;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
WeiboAccount *account = [[[WeiboAccounts shared]accounts] objectAtIndex:indexPath.row];
[[WeiboAccounts shared] setCurrentAccount:account];
[self dismissModalViewControllerAnimated:YES];
}

@end
39 changes: 39 additions & 0 deletions Sample/Controllers/ComposeViewController.h
@@ -0,0 +1,39 @@
//
// ComposeViewController.h
// SinaWeiboOAuthDemo
//
// Created by junmin liu on 11-1-4.
// Copyright 2011 Openlab. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <WeiboSDK/WeiboSDK.h>

@interface ComposeViewController : UIViewController<WeiboRequestDelegate> {
UIBarButtonItem *btnSend;
UIBarButtonItem *btnCancel;
UIBarButtonItem *btnInsert;
UITextView *messageTextField;
UIView *sendingView;
UIImageView *attachmentImage;

NSString *_statusText;

}

@property (nonatomic, retain) IBOutlet UITextView *messageTextField;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *btnSend;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *btnCancel;
@property (nonatomic, retain) IBOutlet UIBarButtonItem *btnInsert;
@property (nonatomic, retain) IBOutlet UIView *sendingView;
@property (nonatomic, retain) IBOutlet UIImageView *imgAttachment;

@property (nonatomic, copy) NSString *statusText;

- (IBAction)send:(id)sender;

- (IBAction)cancel:(id)sender;

- (IBAction)insert:(id)sender;

@end

0 comments on commit 522a037

Please sign in to comment.