Skip to content

Commit ddbb281

Browse files
committed
新浪分享添加一个编辑页面。。
1 parent 79bdf77 commit ddbb281

File tree

4 files changed

+77
-43
lines changed

4 files changed

+77
-43
lines changed

Coding_iOS/AppDelegate.m

+17-1
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,29 @@ - (void)completionStartAnimationWithOptions:(NSDictionary *)launchOptions{
118118
// UMENG 统计
119119
[MobClick startWithAppkey:kUmeng_AppKey reportPolicy:BATCH channelId:nil];
120120

121-
// UMENG Social
121+
// UMENG Social Account
122122
[UMSocialData setAppKey:kUmeng_AppKey];
123123
[UMSocialWechatHandler setWXAppId:kSocial_WX_ID appSecret:kSocial_WX_Secret url:[NSObject baseURLStr]];
124124
[UMSocialQQHandler setQQWithAppId:kSocial_QQ_ID appKey:kSocial_QQ_Secret url:[NSObject baseURLStr]];
125125
[ENSession setSharedSessionConsumerKey:kSocial_EN_Key consumerSecret:kSocial_EN_Secret optionalHost:nil];
126126
[UMSocialSinaSSOHandler openNewSinaSSOWithRedirectURL:kSocial_Sina_RedirectURL];
127127

128+
// UMENG Social Config
129+
[UMSocialConfig setFollowWeiboUids:@{UMShareToSina : kSocial_Sina_OfficailAccount}];//设置默认关注官方账号
130+
[UMSocialConfig setFinishToastIsHidden:YES position:UMSocialiToastPositionCenter];
131+
[UMSocialConfig setNavigationBarConfig:^(UINavigationBar *bar, UIButton *closeButton, UIButton *backButton, UIButton *postButton, UIButton *refreshButton, UINavigationItem *navigationItem) {
132+
if (bar) {
133+
[bar setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:[NSObject baseURLStrIsTest]? @"0x3bbd79" : @"0x28303b"]] forBarMetrics:UIBarMetricsDefault];
134+
}
135+
if (navigationItem) {
136+
if ([[navigationItem titleView] isKindOfClass:[UILabel class]]) {
137+
UILabel *titleL = (UILabel *)[navigationItem titleView];
138+
titleL.font = [UIFont boldSystemFontOfSize:kNavTitleFontSize];
139+
titleL.textColor = [UIColor whiteColor];
140+
}
141+
}
142+
}];
143+
128144
// 信鸽推送
129145
[XGPush startApp:kXGPush_Id appKey:kXGPush_Key];
130146
[Login setXGAccountWithCurUser];

Coding_iOS/Coding_iOS-Prefix.pch.example

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#define kSocial_EN_Key @""
6363
#define kSocial_EN_Secret @""
6464
#define kSocial_Sina_RedirectURL @""
65+
#define kSocial_Sina_OfficailAccount @""
6566

6667
//信鸽推送
6768
#define kXGPush_Id 123456

Coding_iOS/Controllers/ConversationViewController.m

+14-14
Original file line numberDiff line numberDiff line change
@@ -224,20 +224,20 @@ - (void)stopPolling{
224224
}
225225

226226
- (void)doPoll{
227-
// if (!_myPriMsgs || _myPriMsgs.isLoading) {
228-
// return;
229-
// }
230-
// if (_myPriMsgs.list.count <= 0) {
231-
// [self refreshLoadMore:NO];
232-
// return;
233-
// }
234-
// __weak typeof(self) weakSelf = self;
235-
// [[Coding_NetAPIManager sharedManager] request_Fresh_PrivateMessages:_myPriMsgs andBlock:^(id data, NSError *error) {
236-
// if (data && [(NSArray *)data count] > 0) {
237-
// [weakSelf.myPriMsgs configWithPollArray:data];
238-
// [weakSelf dataChangedWithError:NO scrollToBottom:YES animated:YES];
239-
// }
240-
// }];
227+
if (!_myPriMsgs || _myPriMsgs.isLoading) {
228+
return;
229+
}
230+
if (_myPriMsgs.list.count <= 0) {
231+
[self refreshLoadMore:NO];
232+
return;
233+
}
234+
__weak typeof(self) weakSelf = self;
235+
[[Coding_NetAPIManager sharedManager] request_Fresh_PrivateMessages:_myPriMsgs andBlock:^(id data, NSError *error) {
236+
if (data && [(NSArray *)data count] > 0) {
237+
[weakSelf.myPriMsgs configWithPollArray:data];
238+
[weakSelf dataChangedWithError:NO scrollToBottom:YES animated:YES];
239+
}
240+
}];
241241
}
242242

243243
#pragma mark Table M

Coding_iOS/Views/CodingShareView.m

+45-28
Original file line numberDiff line numberDiff line change
@@ -274,31 +274,31 @@ - (void)p_doShareToSnsName:(NSString *)snsName{
274274
}else if ([snsName isEqualToString:@"coding"]){
275275
PrivateMessage *curMsg = [PrivateMessage privateMessageWithObj:[self p_shareLinkStr] andFriend:nil];
276276
[self willTranspondMessage:curMsg];
277-
}else if ([snsName isEqualToString:@"sina"]){
278-
NSString *shareTitle, *shareText, *shareTail;
279-
shareTitle = [NSString stringWithFormat:@"%@", [self p_shareTitle]];
280-
shareText = [self p_shareText];
281-
shareTail = [NSString stringWithFormat:@"%@(分享自@Coding)", [self p_shareLinkStr]];
282-
NSInteger maxShareLength = 140;
283-
NSInteger maxTextLength = maxShareLength - shareTitle.length - shareTail.length;
284-
if (shareText.length > maxTextLength) {
285-
shareText = [shareText stringByReplacingCharactersInRange:NSMakeRange(maxTextLength - 3, shareText.length - (maxTextLength - 3)) withString:@"..."];
286-
}
287-
NSString *shareContent = [NSString stringWithFormat:@"%@%@%@", shareTitle, shareText, shareTail];
288-
[self showStatusBarQueryStr:@"正在分享到新浪微博"];
289-
290-
UMSocialUrlResource *urlResource = nil;
291-
NSString *imageUrl = [self p_imageUrlSquare:NO];
292-
if (imageUrl.length > 0) {
293-
urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeImage url:imageUrl];
294-
}
295-
[[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToSina] content:shareContent image:nil location:nil urlResource:urlResource presentedController:[BaseViewController presentingVC] completion:^(UMSocialResponseEntity *response) {
296-
if (response.responseCode == UMSResponseCodeSuccess) {
297-
[self showStatusBarSuccessStr:@"分享成功"];
298-
}else{
299-
[self showStatusBarErrorStr:@"分享失败"];
300-
}
301-
}];
277+
// }else if ([snsName isEqualToString:@"sina"]){
278+
// NSString *shareTitle, *shareText, *shareTail;
279+
// shareTitle = [NSString stringWithFormat:@"「%@」", [self p_shareTitle]];
280+
// shareText = [self p_shareText];
281+
// shareTail = [NSString stringWithFormat:@"%@(分享自@Coding)", [self p_shareLinkStr]];
282+
// NSInteger maxShareLength = 140;
283+
// NSInteger maxTextLength = maxShareLength - shareTitle.length - shareTail.length;
284+
// if (shareText.length > maxTextLength) {
285+
// shareText = [shareText stringByReplacingCharactersInRange:NSMakeRange(maxTextLength - 3, shareText.length - (maxTextLength - 3)) withString:@"..."];
286+
// }
287+
// NSString *shareContent = [NSString stringWithFormat:@"%@%@%@", shareTitle, shareText, shareTail];
288+
// [self showStatusBarQueryStr:@"正在分享到新浪微博"];
289+
//
290+
// UMSocialUrlResource *urlResource = nil;
291+
// NSString *imageUrl = [self p_imageUrlSquare:NO];
292+
// if (imageUrl.length > 0) {
293+
// urlResource = [[UMSocialUrlResource alloc] initWithSnsResourceType:UMSocialUrlResourceTypeImage url:imageUrl];
294+
// }
295+
// [[UMSocialDataService defaultDataService] postSNSWithTypes:@[UMShareToSina] content:shareContent image:nil location:nil urlResource:urlResource presentedController:[BaseViewController presentingVC] completion:^(UMSocialResponseEntity *response) {
296+
// if (response.responseCode == UMSResponseCodeSuccess) {
297+
// [self showStatusBarSuccessStr:@"分享成功"];
298+
// }else{
299+
// [self showStatusBarErrorStr:@"分享失败"];
300+
// }
301+
// }];
302302
}else if ([snsName isEqualToString:@"evernote"]){
303303
ENNote *noteToSave = [ENNote new];
304304
noteToSave.title = [self p_shareTitle];
@@ -383,7 +383,9 @@ - (NSString *)p_imageUrlSquare:(BOOL)needSquare{
383383
}else{
384384
imageUrl = obj.src;
385385
}
386-
*stop = YES;
386+
*stop = YES;//结束查询
387+
}else if (!needSquare && obj.type == HtmlMediaItemType_EmotionMonkey){
388+
imageUrl = obj.src;//赋值为猴子,继续查询
387389
}
388390
}];
389391
}
@@ -413,7 +415,7 @@ -(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)respon
413415
if(response.responseCode == UMSResponseCodeSuccess){
414416
NSString *snsName = [[response.data allKeys] firstObject];
415417
NSLog(@"share to sns name is %@",snsName);
416-
[self performSelector:@selector(showHudTipStr:) withObject:@"分享成功" afterDelay:0.3];
418+
[self performSelector:@selector(showStatusBarSuccessStr:) withObject:@"分享成功" afterDelay:0.3];
417419
}
418420
}
419421

@@ -422,7 +424,7 @@ -(void)didSelectSocialPlatform:(NSString *)platformName withSocialData:(UMSocial
422424
{
423425
socialData.shareText = [self p_shareText];
424426
socialData.shareImage = [UIImage imageNamed:@"logo_about"];
425-
NSString *imageUrl = [self p_imageUrlSquare:YES];
427+
NSString *imageUrl = [self p_imageUrlSquare:![platformName isEqualToString:@"sina"]];
426428
socialData.urlResource.url = imageUrl;
427429
socialData.urlResource.resourceType = imageUrl.length > 0? UMSocialUrlResourceTypeImage: UMSocialUrlResourceTypeDefault;
428430
}
@@ -449,7 +451,22 @@ -(void)didSelectSocialPlatform:(NSString *)platformName withSocialData:(UMSocial
449451
qzoneData.title = [self p_shareTitle];
450452
qzoneData.url = [self p_shareLinkStr];
451453
socialData.extConfig.qzoneData = qzoneData;
454+
}else if ([platformName isEqualToString:@"sina"]){
455+
NSString *shareTitle, *shareText, *shareTail;
456+
shareTitle = [NSString stringWithFormat:@"%@", [self p_shareTitle]];
457+
shareText = [self p_shareText];
458+
shareTail = [NSString stringWithFormat:@"%@(分享自@Coding)", [self p_shareLinkStr]];
459+
NSInteger maxShareLength = 140;
460+
NSInteger maxTextLength = maxShareLength - shareTitle.length - shareTail.length;
461+
if (shareText.length > maxTextLength) {
462+
shareText = [shareText stringByReplacingCharactersInRange:NSMakeRange(maxTextLength - 3, shareText.length - (maxTextLength - 3)) withString:@"..."];
463+
}
464+
NSString *shareContent = [NSString stringWithFormat:@"%@%@%@", shareTitle, shareText, shareTail];
465+
466+
socialData.shareText = shareContent;
467+
socialData.shareImage = nil;
452468
}
469+
453470
NSLog(@"%@ : %@", platformName, socialData);
454471
}
455472

0 commit comments

Comments
 (0)