澎湃iPad上线版本

sinaAndWeChatCell.m 4.0KB

    // // sinaAndWeChatCell.m // ThePaperDemo // // Created by scar1900 on 14-9-22. // Copyright (c) 2014年 scar1900. All rights reserved. // #import "sinaAndWeChatCell.h" #import "blueButton.h" #import "shareUtil.h" @interface sinaAndWeChatCell() @property(nonatomic, strong)blueButton *sinaBtn; @property(nonatomic, strong)blueButton *weChatHaoyou; @property(nonatomic, strong)blueButton *weChatPengyouquan; @end @implementation sinaAndWeChatCell @synthesize contentBO; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code self.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self.contentView addSubview:self.sinaBtn]; [self.contentView addSubview:self.weChatHaoyou]; [self.contentView addSubview:self.weChatPengyouquan]; } return self; } - (blueButton*)sinaBtn { if (!_sinaBtn) { _sinaBtn = [[blueButton alloc]initWithFrame:CGRectZero withColor:[UIColor colorWithHexString:@"0xcf803d"]]; _sinaBtn.shareImageView.image = Image(@"detailPage/sina.png"); _sinaBtn.textLabel.text = @"新浪微博"; [_sinaBtn addTarget:self action:@selector(sinaEvent:) forControlEvents:UIControlEventTouchUpInside]; } return _sinaBtn; } - (blueButton*)weChatHaoyou { if (!_weChatHaoyou) { _weChatHaoyou = [[blueButton alloc]initWithFrame:CGRectZero withColor:[UIColor colorWithHexString:@"0x61a829"]]; _weChatHaoyou.shareImageView.image = Image(@"detailPage/weChatHaoyou.png"); _weChatHaoyou.textLabel.text = @"微信好友"; [_weChatHaoyou addTarget:self action:@selector(haoyouEvent:) forControlEvents:UIControlEventTouchUpInside]; } if (![shareUtil isHaveWeChatClient]) { _weChatHaoyou.enabled = NO; }else _weChatHaoyou.enabled = YES; return _weChatHaoyou; } - (blueButton*)weChatPengyouquan { if (!_weChatPengyouquan) { _weChatPengyouquan = [[blueButton alloc]initWithFrame:CGRectZero withColor:[UIColor colorWithHexString:@"0x9cc730"]]; _weChatPengyouquan.shareImageView.image = Image(@"detailPage/weChatPengyouquan.png"); _weChatPengyouquan.textLabel.text = @"微信朋友圈"; [_weChatPengyouquan addTarget:self action:@selector(pengyouquanEvent:) forControlEvents:UIControlEventTouchUpInside]; } if (![shareUtil isHaveWeChatClient]) { _weChatPengyouquan.enabled = NO; }else _weChatPengyouquan.enabled = YES; return _weChatPengyouquan; } - (void)sinaEvent:(UIButton*)btn { [shareUtil shareNews:self.contentBO.shareUrl imageUrl:self.contentBO.sharePic title:self.contentBO.name summary:nil shareType:sinaWeiBoShareType shareStyle:shareNewsStyle completion:nil]; } //微信好友分享 - (void)haoyouEvent:(UIButton*)btn { [shareUtil shareNews:self.contentBO.shareUrl imageUrl:self.contentBO.sharePic title:self.contentBO.name summary:self.contentBO.summary shareType:weChatSessionShareType shareStyle:shareNewsStyle completion:nil]; } //微信朋友圈分享 - (void)pengyouquanEvent:(UIButton*)btn { [shareUtil shareNews:self.contentBO.shareUrl imageUrl:self.contentBO.sharePic title:self.contentBO.name summary:nil shareType:weChatTimeLineShareType shareStyle:shareNewsStyle completion:nil]; } - (void)layoutSubviews { CGFloat padding = 0; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) { padding = 125; } self.sinaBtn.frame = CGRectMake(padding, 0, 436/2, 35); self.weChatHaoyou.frame = CGRectMake(CGRectGetMaxX(self.sinaBtn.frame)+7/2, CGRectGetMinY(self.sinaBtn.frame), 436/2, 35); self.weChatPengyouquan.frame = CGRectMake(CGRectGetMaxX(self.weChatHaoyou.frame)+7/2, CGRectGetMinY(self.sinaBtn.frame), 436/2, 35); [super layoutSubviews]; } @end