Commit e1a2aca9 authored by zhu's avatar zhu

分享截屏

parent 4650a3d1
......@@ -13,6 +13,7 @@
#import "SeceneLibraryView.h"
#import "ProductLibraryView.h"
#import "ShoppingView.h"
#import "ShareViewController.h"
@protocol FollowHeartViewAddpicturedelegate <NSObject>
@required
......@@ -22,7 +23,7 @@
@end
@interface FollowHeartViewController : BaseViewController<LeftViewBtnClickdelegate,RightViewBtnClickdelegate,FootViewBtnClickdelegate,UIGestureRecognizerDelegate,AddSecenePicturedelegate,AddProductPicturedelegate>
@interface FollowHeartViewController : BaseViewController<LeftViewBtnClickdelegate,RightViewBtnClickdelegate,FootViewBtnClickdelegate,UIGestureRecognizerDelegate,AddSecenePicturedelegate,AddProductPicturedelegate,SharePicturedelegate>
@property (nonatomic,assign) id<FollowHeartViewAddpicturedelegate> delegate;
@property (nonatomic,strong) LeftSubView *leftSubView;
@property (nonatomic,strong) RightSubView *rightSubView;
......
......@@ -57,7 +57,7 @@
break;
case 102: //分享
{
[self addShareView:button];
}
break;
case 103: //自定义场景
......@@ -92,6 +92,20 @@
break;
}
}
-(void)addShareView:(UIButton *)sender
{
ShareViewController *shareVC = [[ShareViewController alloc]init];
shareVC.delegate = self;
shareVC.preferredContentSize = CGSizeMake(280, 150);
shareVC.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *pop = shareVC.popoverPresentationController;
// 箭头方向
pop.permittedArrowDirections = UIPopoverArrowDirectionAny;
pop.sourceView = shareVC.view;
pop.barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:sender];
[self presentViewController:shareVC animated:YES completion:nil];
}
//场景赋图回调
- (void)resetSuperBackGroundImage:(UIImage*)image
......@@ -118,6 +132,12 @@
{
[self.rightSubView addRightSubViewImage:image productModel:productModel];
}
//分享回调
- (void)ShareProductImage:(UIImage *)image
{
// 先截屏 并保存图片
[self savePhoto];
}
//全屏
-(void)setViewAnimations:(UIButton *)sender
{
......@@ -184,6 +204,73 @@
[self.view addSubview:self.shoppingView.view];
}
// 保存图片到相册功能,ALAssetsLibraryiOS9.0 以后用photoliabary 替代,
-(void)savePhoto
{
UIImage * image = [self captureImageFromView:self.view];
[self saveImageToPhotos:image];
//
// PhysicalAddress
//// * library = [ALAssetsLibrary new];
//
//// NSData * data = UIImageJPEGRepresentation(image, 1.0);
////
//// [library writeImageDataToSavedPhotosAlbum:data metadata:nil completionBlock:nil];
}
- (void)saveImageToPhotos:(UIImage*)savedImage
{
UIImageWriteToSavedPhotosAlbum(savedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
}
// 指定回调方法
- (void)image: (UIImage *) image didFinishSavingWithError: (NSError *) error contextInfo: (void *) contextInfo
{
NSString *msg = nil ;
if(error != NULL){
msg = @"保存图片失败" ;
}else{
msg = @"保存图片成功" ;
// 保存成功后添加到footview
[self addSeceneImage:image];
}
}
//截图功能
-(UIImage *)captureImageFromView:(UIView *)view
{
CGRect screenRect = [view bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[view.layer renderInContext:ctx];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
......
//
// ShareViewController.h
// Lighting
//
// Created by mac on 16/5/23.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "BaseViewController.h"
@protocol SharePicturedelegate <NSObject>
@required
//回调
- (void)ShareProductImage:(UIImage *)image ;
@end
@interface ShareViewController : BaseViewController
@property (nonatomic,assign) id<SharePicturedelegate> delegate;
@property (nonatomic,strong) UIButton *weiXinFriend;
@property (nonatomic,strong) UIButton *weiXinFriendCircle;
@property (nonatomic,strong) UIButton *sinaMicroBlog ;
@end
//
// ShareViewController.m
// Lighting
//
// Created by mac on 16/5/23.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "ShareViewController.h"
@interface ShareViewController ()
@end
@implementation ShareViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self initSubview];
}
-(void)initSubview
{
self.weiXinFriend=[[UIButton alloc]initWithFrame:CGRectMake(25, 25,60 , 60)];
[self.weiXinFriend setBackgroundImage:[UIImage imageNamed:@"wechat"] forState:UIControlStateNormal];
self.weiXinFriend.tag=101;
[self.weiXinFriend addTarget:self action:@selector(sharePicture:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.weiXinFriend];
UILabel *lable1=[[UILabel alloc]initWithFrame:CGRectMake(25, 90, 60, 40)];
lable1.text=@"微信好友";
lable1.font=[UIFont systemFontOfSize:12];
[self.view addSubview:lable1];
self.weiXinFriendCircle=[[UIButton alloc]initWithFrame:CGRectMake(25+25+60, 25,60 , 60)];
[self.weiXinFriendCircle setBackgroundImage:[UIImage imageNamed:@"Friends-Circle"] forState:UIControlStateNormal];
self.weiXinFriendCircle.tag=102;
[self.weiXinFriendCircle addTarget:self action:@selector(sharePicture:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.weiXinFriendCircle];
UILabel *lable2=[[UILabel alloc]initWithFrame:CGRectMake(25+25+60, 90, 60, 40)];
lable2.text=@"微信朋友圈";
lable2.font=[UIFont systemFontOfSize:12];
[self.view addSubview:lable2];
self.sinaMicroBlog=[[UIButton alloc]initWithFrame:CGRectMake(25+25+60+25+60, 25,60 , 60)];
[self.sinaMicroBlog setBackgroundImage:[UIImage imageNamed:@"weibo"] forState:UIControlStateNormal];
self.sinaMicroBlog.tag=103;
[self.sinaMicroBlog addTarget:self action:@selector(sharePicture:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.sinaMicroBlog];
UILabel *lable3=[[UILabel alloc]initWithFrame:CGRectMake(25+25+60+25+60, 90, 60, 40)];
lable3.text=@"新浪微博";
lable3.font=[UIFont systemFontOfSize:12];
[self.view addSubview:lable3];
}
-(void)sharePicture:(UIButton*)sender
{
if ([self.delegate respondsToSelector:@selector(addProductImage:productModel:)]) {
[self.delegate ShareProductImage:nil];
}
switch (sender.tag) {
case 101:
{
}
break;
case 102:
{
}
break;
case 103:
{
}
break;
default:
break;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
......@@ -18,6 +18,8 @@
04A14A2B1CE0FC7F00DAD5F3 /* FootSubView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A14A2A1CE0FC7F00DAD5F3 /* FootSubView.m */; };
04F9EE181CF2235000BD729F /* ShoppingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F9EE171CF2235000BD729F /* ShoppingView.m */; };
04F9EE1B1CF22B5900BD729F /* ShoppingCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F9EE1A1CF22B5900BD729F /* ShoppingCell.m */; };
04F9EE1E1CF25F7300BD729F /* ShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04F9EE1D1CF25F7300BD729F /* ShareViewController.m */; };
04F9EE221CF27B1D00BD729F /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04F9EE211CF27B1D00BD729F /* CoreTelephony.framework */; };
060D397C1CE45CFE0082AECD /* ImageCropperView.m in Sources */ = {isa = PBXBuildFile; fileRef = 060D39791CE45CFE0082AECD /* ImageCropperView.m */; };
060D397D1CE45CFE0082AECD /* UIImage+Rotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 060D397B1CE45CFE0082AECD /* UIImage+Rotation.m */; };
2906B5D71CD89246000849B4 /* ClientDetailsTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2906B5D61CD89246000849B4 /* ClientDetailsTableViewCell.m */; };
......@@ -127,7 +129,6 @@
29F725FE1CE1928F0072FE0E /* opple_objc_json_client.m in Sources */ = {isa = PBXBuildFile; fileRef = 29F725FD1CE1928F0072FE0E /* opple_objc_json_client.m */; };
29F726011CE1D05D0072FE0E /* ScreeningCollectionReusableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 29F726001CE1D05D0072FE0E /* ScreeningCollectionReusableView.m */; };
29F726041CE1E96E0072FE0E /* ScreeningSecondCollectionReusableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 29F726031CE1E96E0072FE0E /* ScreeningSecondCollectionReusableView.m */; };
DCA2F01D27F1F4FC548C6DF7 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2DB768A1F2B4AFFF8B89F1D1 /* libPods.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
......@@ -153,6 +154,10 @@
04F9EE171CF2235000BD729F /* ShoppingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShoppingView.m; sourceTree = "<group>"; };
04F9EE191CF22B5900BD729F /* ShoppingCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShoppingCell.h; sourceTree = "<group>"; };
04F9EE1A1CF22B5900BD729F /* ShoppingCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShoppingCell.m; sourceTree = "<group>"; };
04F9EE1C1CF25F7300BD729F /* ShareViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareViewController.h; sourceTree = "<group>"; };
04F9EE1D1CF25F7300BD729F /* ShareViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShareViewController.m; sourceTree = "<group>"; };
04F9EE1F1CF27AF900BD729F /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
04F9EE211CF27B1D00BD729F /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
060D39781CE45CFE0082AECD /* ImageCropperView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageCropperView.h; sourceTree = "<group>"; };
060D39791CE45CFE0082AECD /* ImageCropperView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageCropperView.m; sourceTree = "<group>"; };
060D397A1CE45CFE0082AECD /* UIImage+Rotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Rotation.h"; sourceTree = "<group>"; };
......@@ -357,7 +362,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
DCA2F01D27F1F4FC548C6DF7 /* libPods.a in Frameworks */,
04F9EE221CF27B1D00BD729F /* CoreTelephony.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -415,6 +420,8 @@
0470D6131CE2938000647F0F /* ProductLibraryView.m */,
04F9EE161CF2235000BD729F /* ShoppingView.h */,
04F9EE171CF2235000BD729F /* ShoppingView.m */,
04F9EE1C1CF25F7300BD729F /* ShareViewController.h */,
04F9EE1D1CF25F7300BD729F /* ShareViewController.m */,
);
name = subView;
sourceTree = "<group>";
......@@ -1207,6 +1214,8 @@
4333C4B25549A396FC0CD944 /* Frameworks */ = {
isa = PBXGroup;
children = (
04F9EE211CF27B1D00BD729F /* CoreTelephony.framework */,
04F9EE1F1CF27AF900BD729F /* SystemConfiguration.framework */,
2DB768A1F2B4AFFF8B89F1D1 /* libPods.a */,
);
name = Frameworks;
......@@ -1266,6 +1275,7 @@
knownRegions = (
en,
Base,
"zh-Hans",
);
mainGroup = 29706D981CD082980003C412;
productRefGroup = 29706DA21CD082990003C412 /* Products */;
......@@ -1399,6 +1409,7 @@
2962D0791CD1CBC60058829D /* NetworkRequestClassManager.m in Sources */,
29F725FB1CE17B0D0072FE0E /* Shoppersmanager.m in Sources */,
29EAAEA01CDC79DC00C4DBA2 /* CustomerOrderViewController.m in Sources */,
04F9EE1E1CF25F7300BD729F /* ShareViewController.m in Sources */,
2928F8321CD09E320036D761 /* Toolview.m in Sources */,
2942F8A61CDD80C2005B377E /* authenticateView.m in Sources */,
044CD6F11CEB81350004A715 /* ProductCollectionPictureCell.m in Sources */,
......@@ -1581,11 +1592,23 @@
CODE_SIGN_IDENTITY = "iPhone Developer: 云霄 曹 (WM8ZU7YY98)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: 云霄 曹 (WM8ZU7YY98)";
COMPRESS_PNG_FILES = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/Tools/ShareSDK/Connection",
"$(PROJECT_DIR)/Tools/ShareSDK/Core",
"$(PROJECT_DIR)/Tools/ShareSDK/Extend/QQConnectSDK",
"$(PROJECT_DIR)/Tools/ShareSDK/Extend/RenRenSDK",
"$(PROJECT_DIR)/Tools/ShareSDK",
"$(PROJECT_DIR)/Tools/ShareSDK/UI",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SRCROOT)/Tools/PrefixHeader.pch";
INFOPLIST_FILE = Lighting/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(PROJECT_DIR)/Tools/ShareSDK/Extend/SinaWeiboSDK",
"$(PROJECT_DIR)/Tools/ShareSDK/Extend/WeChatSDK",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
......@@ -1633,11 +1656,24 @@
CODE_SIGN_IDENTITY = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COMPRESS_PNG_FILES = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/Tools/ShareSDK/Connection",
"$(PROJECT_DIR)/Tools/ShareSDK/Core",
"$(PROJECT_DIR)/Tools/ShareSDK/Extend/QQConnectSDK",
"$(PROJECT_DIR)/Tools/ShareSDK/Extend/RenRenSDK",
"$(PROJECT_DIR)/Tools/ShareSDK",
"$(PROJECT_DIR)/Tools/ShareSDK/UI",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SRCROOT)/Tools/PrefixHeader.pch";
INFOPLIST_FILE = Lighting/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Tools/ShareSDK/Extend/SinaWeiboSDK",
"$(PROJECT_DIR)/Tools/ShareSDK/Extend/WeChatSDK",
);
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
......
......@@ -18,6 +18,15 @@
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>weixin</string>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment