This commit is contained in:
2014-08-08 11:29:05 +08:00
parent b9421d103b
commit a798497312
35 changed files with 12014 additions and 2 deletions
+121
View File
@@ -7,6 +7,11 @@
objects = {
/* Begin PBXBuildFile section */
04C541E9AB294DF5BE18D1BB /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A671F2F14AEE4277BE5F0824 /* libPods.a */; };
A9543E3F1963ACB2006CC216 /* MessageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9543E3E1963ACB2006CC216 /* MessageViewController.m */; };
A958AF9B196E42690029EE41 /* fish_ku@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A958AF9A196E42690029EE41 /* fish_ku@2x.png */; };
A958AFC0196E5F9C0029EE41 /* fish_heng.gif in Resources */ = {isa = PBXBuildFile; fileRef = A958AFBF196E5F9C0029EE41 /* fish_heng.gif */; };
A98624F41963D54000416F38 /* test.gif in Resources */ = {isa = PBXBuildFile; fileRef = A98624F31963D54000416F38 /* test.gif */; };
A9971AA819629A070028FB1E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9971AA719629A070028FB1E /* Foundation.framework */; };
A9971AAA19629A070028FB1E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9971AA919629A070028FB1E /* CoreGraphics.framework */; };
A9971AAC19629A070028FB1E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9971AAB19629A070028FB1E /* UIKit.framework */; };
@@ -19,6 +24,16 @@
A9971AC319629A070028FB1E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9971AAB19629A070028FB1E /* UIKit.framework */; };
A9971ACB19629A070028FB1E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A9971AC919629A070028FB1E /* InfoPlist.strings */; };
A9971ACD19629A070028FB1E /* Ash_FirstTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A9971ACC19629A070028FB1E /* Ash_FirstTests.m */; };
A9A55C5019865C7E004C5BB5 /* button.9.png in Resources */ = {isa = PBXBuildFile; fileRef = A9A55C4F19865C7E004C5BB5 /* button.9.png */; };
A9CEB7051962A6BA00C54CB0 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9CEB7031962A6BA00C54CB0 /* MainViewController.m */; };
A9CEB7061962A6BA00C54CB0 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9CEB7041962A6BA00C54CB0 /* MainViewController.xib */; };
A9ECA8F3198238A60035277D /* AssetHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = A9ECA8E9198238A60035277D /* AssetHelper.m */; };
A9ECA8F4198238A60035277D /* DoAlbumCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A9ECA8EB198238A60035277D /* DoAlbumCell.m */; };
A9ECA8F5198238A60035277D /* DoAlbumCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9ECA8EC198238A60035277D /* DoAlbumCell.xib */; };
A9ECA8F6198238A60035277D /* DoImagePickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9ECA8EE198238A60035277D /* DoImagePickerController.m */; };
A9ECA8F7198238A60035277D /* DoImagePickerController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9ECA8EF198238A60035277D /* DoImagePickerController.xib */; };
A9ECA8F8198238A60035277D /* DoPhotoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A9ECA8F1198238A60035277D /* DoPhotoCell.m */; };
A9ECA8F9198238A60035277D /* DoPhotoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9ECA8F2198238A60035277D /* DoPhotoCell.xib */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -32,6 +47,13 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
A66ECFF2A9974F1F991AD71C /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = "<group>"; };
A671F2F14AEE4277BE5F0824 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
A9543E3D1963ACB2006CC216 /* MessageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageViewController.h; sourceTree = "<group>"; };
A9543E3E1963ACB2006CC216 /* MessageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageViewController.m; sourceTree = "<group>"; };
A958AF9A196E42690029EE41 /* fish_ku@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "fish_ku@2x.png"; sourceTree = "<group>"; };
A958AFBF196E5F9C0029EE41 /* fish_heng.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = fish_heng.gif; sourceTree = "<group>"; };
A98624F31963D54000416F38 /* test.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = test.gif; sourceTree = "<group>"; };
A9971AA419629A070028FB1E /* Ash_First.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Ash_First.app; sourceTree = BUILT_PRODUCTS_DIR; };
A9971AA719629A070028FB1E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
A9971AA919629A070028FB1E /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
@@ -48,6 +70,21 @@
A9971AC819629A070028FB1E /* Ash_FirstTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Ash_FirstTests-Info.plist"; sourceTree = "<group>"; };
A9971ACA19629A070028FB1E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
A9971ACC19629A070028FB1E /* Ash_FirstTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Ash_FirstTests.m; sourceTree = "<group>"; };
A9A55C4F19865C7E004C5BB5 /* button.9.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = button.9.png; sourceTree = "<group>"; };
A9CEB7021962A6BA00C54CB0 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = "<group>"; };
A9CEB7031962A6BA00C54CB0 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = "<group>"; };
A9CEB7041962A6BA00C54CB0 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainViewController.xib; sourceTree = "<group>"; };
A9ECA8E8198238A60035277D /* AssetHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AssetHelper.h; sourceTree = "<group>"; };
A9ECA8E9198238A60035277D /* AssetHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AssetHelper.m; sourceTree = "<group>"; };
A9ECA8EA198238A60035277D /* DoAlbumCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DoAlbumCell.h; sourceTree = "<group>"; };
A9ECA8EB198238A60035277D /* DoAlbumCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoAlbumCell.m; sourceTree = "<group>"; };
A9ECA8EC198238A60035277D /* DoAlbumCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DoAlbumCell.xib; sourceTree = "<group>"; };
A9ECA8ED198238A60035277D /* DoImagePickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DoImagePickerController.h; sourceTree = "<group>"; };
A9ECA8EE198238A60035277D /* DoImagePickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoImagePickerController.m; sourceTree = "<group>"; };
A9ECA8EF198238A60035277D /* DoImagePickerController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DoImagePickerController.xib; sourceTree = "<group>"; };
A9ECA8F0198238A60035277D /* DoPhotoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DoPhotoCell.h; sourceTree = "<group>"; };
A9ECA8F1198238A60035277D /* DoPhotoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DoPhotoCell.m; sourceTree = "<group>"; };
A9ECA8F2198238A60035277D /* DoPhotoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DoPhotoCell.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -58,6 +95,7 @@
A9971AAA19629A070028FB1E /* CoreGraphics.framework in Frameworks */,
A9971AAC19629A070028FB1E /* UIKit.framework in Frameworks */,
A9971AA819629A070028FB1E /* Foundation.framework in Frameworks */,
04C541E9AB294DF5BE18D1BB /* libPods.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -77,10 +115,12 @@
A9971A9B19629A070028FB1E = {
isa = PBXGroup;
children = (
A9ECA8E7198238A60035277D /* DoImagePicker */,
A9971AAD19629A070028FB1E /* Ash_First */,
A9971AC619629A070028FB1E /* Ash_FirstTests */,
A9971AA619629A070028FB1E /* Frameworks */,
A9971AA519629A070028FB1E /* Products */,
A66ECFF2A9974F1F991AD71C /* Pods.xcconfig */,
);
sourceTree = "<group>";
};
@@ -100,6 +140,7 @@
A9971AA919629A070028FB1E /* CoreGraphics.framework */,
A9971AAB19629A070028FB1E /* UIKit.framework */,
A9971AC019629A070028FB1E /* XCTest.framework */,
A671F2F14AEE4277BE5F0824 /* libPods.a */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -107,10 +148,19 @@
A9971AAD19629A070028FB1E /* Ash_First */ = {
isa = PBXGroup;
children = (
A958AFBF196E5F9C0029EE41 /* fish_heng.gif */,
A9A55C4F19865C7E004C5BB5 /* button.9.png */,
A98624F31963D54000416F38 /* test.gif */,
A958AF9A196E42690029EE41 /* fish_ku@2x.png */,
A9971AB619629A070028FB1E /* AppDelegate.h */,
A9971AB719629A070028FB1E /* AppDelegate.m */,
A9971AB919629A070028FB1E /* Images.xcassets */,
A9971AAE19629A070028FB1E /* Supporting Files */,
A9CEB7021962A6BA00C54CB0 /* MainViewController.h */,
A9CEB7031962A6BA00C54CB0 /* MainViewController.m */,
A9CEB7041962A6BA00C54CB0 /* MainViewController.xib */,
A9543E3D1963ACB2006CC216 /* MessageViewController.h */,
A9543E3E1963ACB2006CC216 /* MessageViewController.m */,
);
path = Ash_First;
sourceTree = "<group>";
@@ -144,6 +194,24 @@
name = "Supporting Files";
sourceTree = "<group>";
};
A9ECA8E7198238A60035277D /* DoImagePicker */ = {
isa = PBXGroup;
children = (
A9ECA8E8198238A60035277D /* AssetHelper.h */,
A9ECA8E9198238A60035277D /* AssetHelper.m */,
A9ECA8EA198238A60035277D /* DoAlbumCell.h */,
A9ECA8EB198238A60035277D /* DoAlbumCell.m */,
A9ECA8EC198238A60035277D /* DoAlbumCell.xib */,
A9ECA8ED198238A60035277D /* DoImagePickerController.h */,
A9ECA8EE198238A60035277D /* DoImagePickerController.m */,
A9ECA8EF198238A60035277D /* DoImagePickerController.xib */,
A9ECA8F0198238A60035277D /* DoPhotoCell.h */,
A9ECA8F1198238A60035277D /* DoPhotoCell.m */,
A9ECA8F2198238A60035277D /* DoPhotoCell.xib */,
);
path = DoImagePicker;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -151,9 +219,11 @@
isa = PBXNativeTarget;
buildConfigurationList = A9971AD019629A070028FB1E /* Build configuration list for PBXNativeTarget "Ash_First" */;
buildPhases = (
D1C14D0A6BEF4AEA85277D5C /* Check Pods Manifest.lock */,
A9971AA019629A070028FB1E /* Sources */,
A9971AA119629A070028FB1E /* Frameworks */,
A9971AA219629A070028FB1E /* Resources */,
35CC792A077D4BD185C0D3F4 /* Copy Pods Resources */,
);
buildRules = (
);
@@ -219,7 +289,15 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A9A55C5019865C7E004C5BB5 /* button.9.png in Resources */,
A9ECA8F9198238A60035277D /* DoPhotoCell.xib in Resources */,
A9971AB219629A070028FB1E /* InfoPlist.strings in Resources */,
A9ECA8F5198238A60035277D /* DoAlbumCell.xib in Resources */,
A9CEB7061962A6BA00C54CB0 /* MainViewController.xib in Resources */,
A958AF9B196E42690029EE41 /* fish_ku@2x.png in Resources */,
A9ECA8F7198238A60035277D /* DoImagePickerController.xib in Resources */,
A98624F41963D54000416F38 /* test.gif in Resources */,
A958AFC0196E5F9C0029EE41 /* fish_heng.gif in Resources */,
A9971ABA19629A070028FB1E /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -234,12 +312,51 @@
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
35CC792A077D4BD185C0D3F4 /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n";
showEnvVarsInLog = 0;
};
D1C14D0A6BEF4AEA85277D5C /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
A9971AA019629A070028FB1E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A9971AB819629A070028FB1E /* AppDelegate.m in Sources */,
A9ECA8F3198238A60035277D /* AssetHelper.m in Sources */,
A9ECA8F4198238A60035277D /* DoAlbumCell.m in Sources */,
A9CEB7051962A6BA00C54CB0 /* MainViewController.m in Sources */,
A9543E3F1963ACB2006CC216 /* MessageViewController.m in Sources */,
A9ECA8F8198238A60035277D /* DoPhotoCell.m in Sources */,
A9ECA8F6198238A60035277D /* DoImagePickerController.m in Sources */,
A9971AB419629A070028FB1E /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -356,6 +473,7 @@
};
A9971AD119629A070028FB1E /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A66ECFF2A9974F1F991AD71C /* Pods.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
@@ -369,6 +487,7 @@
};
A9971AD219629A070028FB1E /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = A66ECFF2A9974F1F991AD71C /* Pods.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
@@ -441,6 +560,7 @@
A9971AD219629A070028FB1E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
A9971AD319629A070028FB1E /* Build configuration list for PBXNativeTarget "Ash_FirstTests" */ = {
isa = XCConfigurationList;
@@ -449,6 +569,7 @@
A9971AD519629A070028FB1E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
+1 -1
View File
@@ -8,7 +8,7 @@
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@interface AppDelegate : UIResponder <UIApplicationDelegate,UITabBarControllerDelegate>
@property (strong, nonatomic) UIWindow *window;
+32 -1
View File
@@ -7,15 +7,39 @@
//
#import "AppDelegate.h"
#import "MainViewController.h"
//#import "ViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UINavigationController *mainViewController = [[UINavigationController alloc] initWithRootViewController:[[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil]];
UINavigationController *viewController = [[UINavigationController alloc] initWithRootViewController:[[MainViewController alloc] init]];
UINavigationController *mainViewController1 = [[UINavigationController alloc] initWithRootViewController:[[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil]];
UITabBarController* tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate = self;
tabBarController.viewControllers = [NSArray arrayWithObjects:mainViewController, mainViewController1,viewController, nil];
tabBarController.title = @"first";
// UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:tabBarController];
// navigationController.title = @"new";
// navigationController.navigationItem.title = @"new";
// navigationController.navigationBarHidden = YES;
self.window.rootViewController = tabBarController;
// self.window.rootViewController = tabBarController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
@@ -46,4 +70,11 @@
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
#pragma mark TabBarControllerDelegate
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
// [self.view addSubview:viewController.view];
// tabBarController.selectedViewController = viewController;
viewController.tabBarItem.badgeValue = [NSString stringWithFormat:@"%d",80];
// viewController.tabBarItem.title = @"aaa";
}
@end
+3
View File
@@ -13,4 +13,7 @@
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "SDWebImage/UIImageView+WebCache.h"
#import "SDWebImage/UIButton+WebCache.h"
#import "SDWebImage/SDImageCache.h"
#endif
+15
View File
@@ -0,0 +1,15 @@
//
// MainViewController.h
// Ash_First
//
// Created by xmfish on 14-7-1.
// Copyright (c) 2014年 xmfish. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <DTCoreText.h>
@interface MainViewController : UIViewController<DTAttributedTextContentViewDelegate>
@property (weak, nonatomic) IBOutlet UIButton *Push;
- (IBAction)pushViewControll:(id)sender;
@end
+86
View File
@@ -0,0 +1,86 @@
//
// MainViewController.m
// Ash_First
//
// Created by xmfish on 14-7-1.
// Copyright (c) 2014年 xmfish. All rights reserved.
//
#import "MainViewController.h"
#import "MessageViewController.h"
#import <DTCoreText.h>
#import <SDWebImage/UIImageView+WebCache.h>
@interface MainViewController ()
@end
@implementation MainViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"123";
self.navigationItem.title = @"woshishui";
// self.navigationController.navigationBarHidden = YES;
NSString* htmlStr = @"<h1>Header</h1><h2>Subheader</h2><p>Some <em>text</em></p><img src=\"test.gif\"/><a href=\"http://bbs.xmfish.com/read.php?tid=10031229\" target=\"_blank\">查看主题</a><span style=\"font-size:15px;\"><img width='32' height='32' src=\"fish_heng.gif\" /></span> ";
htmlStr = @"<span style=\"font-size:15px;\"><img width='32' height='32' src=\"fish_heng.gif\" /></span>";
NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding];
NSAttributedString *string = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL];
DTAttributedTextContentView* _attributedTextContextView;
// _attributedTextContextView.delegate = self;
_attributedTextContextView = nil;
_attributedTextContextView = [[DTAttributedTextContentView alloc] init];
// _attributedTextContextView.edgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
_attributedTextContextView.shouldDrawImages = NO;
_attributedTextContextView.shouldDrawLinks = YES;
_attributedTextContextView.delegate = self;
_attributedTextContextView.backgroundColor = [UIColor clearColor];
_attributedTextContextView.attributedString = string;
_attributedTextContextView.frame = CGRectMake(15, 150, 200, 500);
[self.view addSubview:_attributedTextContextView];
UIEdgeInsets insets = UIEdgeInsetsMake(5, 5, 5, 5);
UIImage *redImage = [[UIImage imageNamed:@"button.9.png"]resizableImageWithCapInsets:insets];
UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 200, 200, 200)];
[imageView setImage:redImage];
[self.view addSubview:imageView];
}
- (UIView *)attributedTextContentView:(DTAttributedTextContentView *)attributedTextContentView viewForAttachment:(DTTextAttachment *)attachment frame:(CGRect)frame
{
UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.layer.masksToBounds = YES;
// if the attachment has a hyperlinkURL then this is currently ignored
[imageView setImageWithURL:attachment.contentURL];
return imageView;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)pushViewControll:(id)sender {
MessageViewController *messageViewController = [[MessageViewController alloc] init];
messageViewController.hidesBottomBarWhenPushed = YES;
// [self presentViewController:messageViewController animated:YES completion:nil];
[self.navigationController pushViewController:messageViewController animated:YES];
// self.tabBarController.tabBar.hidden=YES;
}
@end
+39
View File
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13D65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3746"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MainViewController">
<connections>
<outlet property="Push" destination="w4f-PS-WUf" id="ZNx-0D-jVx"/>
<outlet property="view" destination="1" id="3"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view multipleTouchEnabled="YES" contentMode="scaleToFill" id="1">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="w4f-PS-WUf">
<rect key="frame" x="91" y="119" width="112" height="57"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.40501349679999998" green="0.72713628360000004" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<rect key="contentStretch" x="0.0" y="0.0" width="0.0" height="0.0"/>
<fontDescription key="fontDescription" name="STHeitiSC-Medium" family="Heiti SC" pointSize="15"/>
<inset key="contentEdgeInsets" minX="15" minY="15" maxX="15" maxY="15"/>
<size key="titleShadowOffset" width="40" height="40"/>
<state key="normal" title="你好">
<color key="titleShadowColor" red="1" green="0.37822147691156238" blue="0.16647340829033863" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="pushViewControll:" destination="-1" eventType="touchUpInside" id="kqO-Yc-RsX"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</view>
</objects>
</document>
+13
View File
@@ -0,0 +1,13 @@
//
// MessageViewController.h
// Ash_First
//
// Created by xmfish on 14-7-2.
// Copyright (c) 2014年 xmfish. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MessageViewController : UIViewController
@end
+49
View File
@@ -0,0 +1,49 @@
//
// MessageViewController.m
// Ash_First
//
// Created by xmfish on 14-7-2.
// Copyright (c) 2014年 xmfish. All rights reserved.
//
#import "MessageViewController.h"
#import <SDWebImage/UIImageView+WebCache.h>
@interface MessageViewController ()
@end
@implementation MessageViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"1231131231";
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
NSString *imageUrl = @"http://pic2.bbzhi.com/dongwubizhi/keaixiaogou1920xiaogouxiezhendiyiji/keaixiaogou1920xiaogouxiezhendiyiji_83154_11.jpg";
[imageView setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"test.gif"]];
// [self.view addSubview:imageView];
UITextView* textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 100, 1000, 500)];
NSString *htmlString = @"<h1>Header</h1><h2>Subheader</h2><pSome <em>text</em></p><img width='50' height='100' src='http://cdn.duitang.com/uploads/item/201301/08/20130108192528_wuPLf.gif'/>";
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
textView.attributedText = attributedString;
[self.view addSubview:textView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

+51
View File
@@ -0,0 +1,51 @@
//
// AssetHelper.m
// DoImagePickerController
//
// Created by Donobono on 2014. 1. 23..
//
#import <Foundation/Foundation.h>
#import <AssetsLibrary/AssetsLibrary.h>
#define ASSETHELPER [AssetHelper sharedAssetHelper]
#define ASSET_PHOTO_THUMBNAIL 0
#define ASSET_PHOTO_SCREEN_SIZE 1
#define ASSET_PHOTO_FULL_RESOLUTION 2
@interface AssetHelper : NSObject
- (void)initAsset;
@property (nonatomic, strong) ALAssetsLibrary *assetsLibrary;
@property (nonatomic, strong) NSMutableArray *assetPhotos;
@property (nonatomic, strong) NSMutableArray *assetGroups;
@property (readwrite) BOOL bReverse;
+ (AssetHelper *)sharedAssetHelper;
// get album list from asset
- (void)getGroupList:(void (^)(NSArray *))result;
// get photos from specific album with ALAssetsGroup object
- (void)getPhotoListOfGroup:(ALAssetsGroup *)alGroup result:(void (^)(NSArray *))result;
// get photos from specific album with index of album array
- (void)getPhotoListOfGroupByIndex:(NSInteger)nGroupIndex result:(void (^)(NSArray *))result;
// get photos from camera roll
- (void)getSavedPhotoList:(void (^)(NSArray *))result error:(void (^)(NSError *))error;
- (NSInteger)getGroupCount;
- (NSInteger)getPhotoCountOfCurrentGroup;
- (NSDictionary *)getGroupInfo:(NSInteger)nIndex;
- (void)clearData;
// utils
- (UIImage *)getCroppedImage:(NSURL *)urlImage;
- (UIImage *)getImageFromAsset:(ALAsset *)asset type:(NSInteger)nType;
- (UIImage *)getImageAtIndex:(NSInteger)nIndex type:(NSInteger)nType;
- (ALAsset *)getAssetAtIndex:(NSInteger)nIndex;
@end
+268
View File
@@ -0,0 +1,268 @@
//
// AssetHelper.m
// DoImagePickerController
//
// Created by Donobono on 2014. 1. 23..
//
#import "AssetHelper.h"
@implementation AssetHelper
+ (AssetHelper *)sharedAssetHelper
{
static AssetHelper *_sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedInstance = [[AssetHelper alloc] init];
[_sharedInstance initAsset];
});
return _sharedInstance;
}
- (void)initAsset
{
if (self.assetsLibrary == nil)
{
_assetsLibrary = [[ALAssetsLibrary alloc] init];
NSString *strVersion = [[UIDevice alloc] systemVersion];
if ([strVersion compare:@"5"] >= 0)
[_assetsLibrary writeImageToSavedPhotosAlbum:nil metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) {
}];
}
}
- (void)getGroupList:(void (^)(NSArray *))result
{
[self initAsset];
void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
if (group == nil)
{
if (_bReverse)
_assetGroups = [[NSMutableArray alloc] initWithArray:[[_assetGroups reverseObjectEnumerator] allObjects]];
// end of enumeration
result(_assetGroups);
return;
}
[_assetGroups addObject:group];
};
void (^assetGroupEnumberatorFailure)(NSError *) = ^(NSError *error)
{
NSLog(@"Error : %@", [error description]);
};
_assetGroups = [[NSMutableArray alloc] init];
[_assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:assetGroupEnumerator
failureBlock:assetGroupEnumberatorFailure];
}
- (void)getPhotoListOfGroup:(ALAssetsGroup *)alGroup result:(void (^)(NSArray *))result
{
[self initAsset];
_assetPhotos = [[NSMutableArray alloc] init];
[alGroup setAssetsFilter:[ALAssetsFilter allPhotos]];
[alGroup enumerateAssetsUsingBlock:^(ALAsset *alPhoto, NSUInteger index, BOOL *stop) {
if(alPhoto == nil)
{
if (_bReverse)
_assetPhotos = [[NSMutableArray alloc] initWithArray:[[_assetPhotos reverseObjectEnumerator] allObjects]];
result(_assetPhotos);
return;
}
[_assetPhotos addObject:alPhoto];
}];
}
- (void)getPhotoListOfGroupByIndex:(NSInteger)nGroupIndex result:(void (^)(NSArray *))result
{
[self getPhotoListOfGroup:_assetGroups[nGroupIndex] result:^(NSArray *aResult) {
result(_assetPhotos);
}];
}
- (void)getSavedPhotoList:(void (^)(NSArray *))result error:(void (^)(NSError *))error
{
[self initAsset];
dispatch_async(dispatch_get_main_queue(), ^{
void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop)
{
if ([[group valueForProperty:@"ALAssetsGroupPropertyType"] intValue] == ALAssetsGroupSavedPhotos)
{
[group setAssetsFilter:[ALAssetsFilter allPhotos]];
[group enumerateAssetsUsingBlock:^(ALAsset *alPhoto, NSUInteger index, BOOL *stop) {
if(alPhoto == nil)
{
if (_bReverse)
_assetPhotos = [[NSMutableArray alloc] initWithArray:[[_assetPhotos reverseObjectEnumerator] allObjects]];
result(_assetPhotos);
return;
}
[_assetPhotos addObject:alPhoto];
}];
}
};
void (^assetGroupEnumberatorFailure)(NSError *) = ^(NSError *err)
{
NSLog(@"Error : %@", [err description]);
error(err);
};
_assetPhotos = [[NSMutableArray alloc] init];
[_assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
usingBlock:assetGroupEnumerator
failureBlock:assetGroupEnumberatorFailure];
});
}
- (NSInteger)getGroupCount
{
return _assetGroups.count;
}
- (NSInteger)getPhotoCountOfCurrentGroup
{
return _assetPhotos.count;
}
- (NSDictionary *)getGroupInfo:(NSInteger)nIndex
{
return @{@"name" : [_assetGroups[nIndex] valueForProperty:ALAssetsGroupPropertyName],
@"count" : @([_assetGroups[nIndex] numberOfAssets]),
@"thumbnail" : [UIImage imageWithCGImage:[(ALAssetsGroup*)_assetGroups[nIndex] posterImage]]};
}
- (void)clearData
{
_assetGroups = nil;
_assetPhotos = nil;
}
#pragma mark - utils
- (UIImage *)getCroppedImage:(NSURL *)urlImage
{
__block UIImage *iImage = nil;
__block BOOL bBusy = YES;
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
ALAssetRepresentation *rep = [myasset defaultRepresentation];
NSString *strXMP = rep.metadata[@"AdjustmentXMP"];
if (strXMP == nil || [strXMP isKindOfClass:[NSNull class]])
{
CGImageRef iref = [rep fullResolutionImage];
if (iref)
iImage = [UIImage imageWithCGImage:iref scale:1.0 orientation:(UIImageOrientation)rep.orientation];
else
iImage = nil;
}
else
{
// to get edited photo by photo app
NSData *dXMP = [strXMP dataUsingEncoding:NSUTF8StringEncoding];
CIImage *image = [CIImage imageWithCGImage:rep.fullResolutionImage];
NSError *error = nil;
NSArray *filterArray = [CIFilter filterArrayFromSerializedXMP:dXMP
inputImageExtent:image.extent
error:&error];
if (error) {
NSLog(@"Error during CIFilter creation: %@", [error localizedDescription]);
}
for (CIFilter *filter in filterArray) {
[filter setValue:image forKey:kCIInputImageKey];
image = [filter outputImage];
}
iImage = [UIImage imageWithCIImage:image scale:1.0 orientation:(UIImageOrientation)rep.orientation];
}
bBusy = NO;
};
ALAssetsLibraryAccessFailureBlock failureblock = ^(NSError *myerror)
{
NSLog(@"booya, cant get image - %@",[myerror localizedDescription]);
};
[_assetsLibrary assetForURL:urlImage
resultBlock:resultblock
failureBlock:failureblock];
while (bBusy)
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
return iImage;
}
- (UIImage *)getImageFromAsset:(ALAsset *)asset type:(NSInteger)nType
{
CGImageRef iRef = nil;
if (nType == ASSET_PHOTO_THUMBNAIL)
iRef = [asset thumbnail];
else if (nType == ASSET_PHOTO_SCREEN_SIZE)
iRef = [asset.defaultRepresentation fullScreenImage];
else if (nType == ASSET_PHOTO_FULL_RESOLUTION)
{
NSString *strXMP = asset.defaultRepresentation.metadata[@"AdjustmentXMP"];
NSData *dXMP = [strXMP dataUsingEncoding:NSUTF8StringEncoding];
CIImage *image = [CIImage imageWithCGImage:asset.defaultRepresentation.fullResolutionImage];
NSError *error = nil;
NSArray *filterArray = [CIFilter filterArrayFromSerializedXMP:dXMP
inputImageExtent:image.extent
error:&error];
if (error) {
NSLog(@"Error during CIFilter creation: %@", [error localizedDescription]);
}
for (CIFilter *filter in filterArray) {
[filter setValue:image forKey:kCIInputImageKey];
image = [filter outputImage];
}
UIImage *iImage = [UIImage imageWithCIImage:image scale:1.0 orientation:(UIImageOrientation)asset.defaultRepresentation.orientation];
return iImage;
}
return [UIImage imageWithCGImage:iRef];
}
- (UIImage *)getImageAtIndex:(NSInteger)nIndex type:(NSInteger)nType
{
return [self getImageFromAsset:(ALAsset *)_assetPhotos[nIndex] type:nType];
}
- (ALAsset *)getAssetAtIndex:(NSInteger)nIndex
{
return _assetPhotos[nIndex];
}
@end
+15
View File
@@ -0,0 +1,15 @@
//
// DoAlbumCell.h
// DoImagePickerController
//
// Created by Donobono on 2014. 1. 23..
//
#import <UIKit/UIKit.h>
@interface DoAlbumCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *lbAlbumName;
@property (weak, nonatomic) IBOutlet UILabel *lbCount;
@end
+42
View File
@@ -0,0 +1,42 @@
//
// DoAlbumCell.m
// DoImagePickerController
//
// Created by Donobono on 2014. 1. 23..
//
#import "DoAlbumCell.h"
#import "DoImagePickerController.h"
@implementation DoAlbumCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
if (selected)
{
_lbAlbumName.textColor = [UIColor whiteColor];
_lbCount.textColor = [UIColor whiteColor];
self.contentView.backgroundColor = DO_ALBUM_NAME_TEXT_COLOR;
}
else
{
_lbAlbumName.textColor = DO_ALBUM_NAME_TEXT_COLOR;
_lbCount.textColor = DO_ALBUM_COUNT_TEXT_COLOR;
self.contentView.backgroundColor = [UIColor whiteColor];
}
}
@end
+38
View File
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3746"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="fnV-fg-Jma" customClass="DoAlbumCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="fnV-fg-Jma" id="tN4-1K-F2k">
<rect key="frame" x="0.0" y="0.0" width="320" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="ed6-eU-lrq">
<rect key="frame" x="0.0" y="14" width="254" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Avenir-Medium" family="Avenir" pointSize="16"/>
<color key="textColor" red="0.94117653369999998" green="0.7254902124" blue="0.40392160420000001" alpha="1" colorSpace="deviceRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="10,100" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fdn-DY-gwW">
<rect key="frame" x="262" y="15" width="58" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Avenir-Light" family="Avenir" pointSize="15"/>
<color key="textColor" red="0.96862751250000001" green="0.78431379800000001" blue="0.55686277149999996" alpha="1" colorSpace="deviceRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<outlet property="lbAlbumName" destination="ed6-eU-lrq" id="HcR-vk-wIj"/>
<outlet property="lbCount" destination="fdn-DY-gwW" id="Z4L-dn-HBj"/>
</connections>
</tableViewCell>
</objects>
</document>
+86
View File
@@ -0,0 +1,86 @@
//
// DoImagePickerController.h
// DoImagePickerController
//
// Created by Donobono on 2014. 1. 23..
//
#import <UIKit/UIKit.h>
#define DO_RGB(r, g, b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define DO_RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define DO_MENU_BACK_COLOR DO_RGBA(57, 185, 238, 0.98)
#define DO_SIDE_BUTTON_COLOR DO_RGBA(57, 185, 238, 0.9)
#define DO_ALBUM_NAME_TEXT_COLOR DO_RGB(57, 185, 238)
#define DO_ALBUM_COUNT_TEXT_COLOR DO_RGB(247, 200, 142)
#define DO_BOTTOM_TEXT_COLOR DO_RGB(255, 255, 255)
#define DO_PICKER_RESULT_UIIMAGE 0
#define DO_PICKER_RESULT_ASSET 1
#define DO_NO_LIMIT_SELECT -1
@interface DoImagePickerController : UIViewController
@property (assign, nonatomic) id delegate;
@property (readwrite) NSInteger nMaxCount; // -1 : no limit
@property (readwrite) NSInteger nColumnCount; // 2, 3, or 4
@property (readwrite) NSInteger nResultType; // default : DO_PICKER_RESULT_UIIMAGE
@property (weak, nonatomic) IBOutlet UICollectionView *cvPhotoList;
@property (weak, nonatomic) IBOutlet UITableView *tvAlbumList;
@property (weak, nonatomic) IBOutlet UIView *vDimmed;
// init
- (void)initControls;
- (void)readAlbumList;
// bottom menu
@property (weak, nonatomic) IBOutlet UIView *vBottomMenu;
@property (weak, nonatomic) IBOutlet UIButton *btSelectAlbum;
@property (weak, nonatomic) IBOutlet UIButton *btOK;
@property (weak, nonatomic) IBOutlet UIImageView *ivLine1;
@property (weak, nonatomic) IBOutlet UIImageView *ivLine2;
@property (weak, nonatomic) IBOutlet UILabel *lbSelectCount;
@property (weak, nonatomic) IBOutlet UIImageView *ivShowMark;
- (void)initBottomMenu;
- (IBAction)onSelectPhoto:(id)sender;
- (IBAction)onCancel:(id)sender;
- (IBAction)onSelectAlbum:(id)sender;
- (void)hideBottomMenu;
// side buttons
@property (weak, nonatomic) IBOutlet UIButton *btUp;
@property (weak, nonatomic) IBOutlet UIButton *btDown;
- (IBAction)onUp:(id)sender;
- (IBAction)onDown:(id)sender;
// photos
@property (strong, nonatomic) UIImageView *ivPreview;
- (void)showPhotosInGroup:(NSInteger)nIndex; // nIndex : index in album array
- (void)showPreview:(NSInteger)nIndex; // nIndex : index in photo array
- (void)hidePreview;
// select photos
@property (strong, nonatomic) NSMutableDictionary *dSelected;
@property (strong, nonatomic) NSIndexPath *lastAccessed;
@end
@protocol DoImagePickerControllerDelegate
- (void)didCancelDoImagePickerController;
- (void)didSelectPhotosFromDoImagePickerController:(DoImagePickerController *)picker result:(NSArray *)aSelected;
@end
+546
View File
@@ -0,0 +1,546 @@
//
// DoImagePickerController.m
// DoImagePickerController
//
// Created by Donobono on 2014. 1. 23..
//
#import "DoImagePickerController.h"
#import "AssetHelper.h"
#import "DoAlbumCell.h"
#import "DoPhotoCell.h"
@implementation DoImagePickerController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self initBottomMenu];
[self initControls];
UINib *nib = [UINib nibWithNibName:@"DoPhotoCell" bundle:nil];
[_cvPhotoList registerNib:nib forCellWithReuseIdentifier:@"DoPhotoCell"];
_tvAlbumList.frame = CGRectMake(0, _vBottomMenu.frame.origin.y, self.view.frame.size.width, self.view.frame.size.height);
_tvAlbumList.alpha = 0.0;
[self readAlbumList];
// new photo is located at the first of array
ASSETHELPER.bReverse = YES;
if (_nMaxCount != 1)
{
// init gesture for multiple selection with panning
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onPanForSelection:)];
[self.view addGestureRecognizer:pan];
}
// init gesture for preview
UILongPressGestureRecognizer *longTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onLongTapForPreview:)];
longTap.minimumPressDuration = 0.3;
[self.view addGestureRecognizer:longTap];
// add observer for refresh asset data
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(handleEnterForeground:)
name: UIApplicationWillEnterForegroundNotification
object: nil];
}
- (void)viewDidDisappear:(BOOL)animated
{
if (_nResultType == DO_PICKER_RESULT_UIIMAGE)
[ASSETHELPER clearData];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
}
- (void)handleEnterForeground:(NSNotification*)notification
{
[self readAlbumList];
}
#pragma mark - for init
- (void)initControls
{
// side buttons
_btUp.backgroundColor = DO_SIDE_BUTTON_COLOR;
_btDown.backgroundColor = DO_SIDE_BUTTON_COLOR;
CALayer *layer1 = [_btDown layer];
[layer1 setMasksToBounds:YES];
[layer1 setCornerRadius:_btDown.frame.size.height / 2.0 - 1];
CALayer *layer2 = [_btUp layer];
[layer2 setMasksToBounds:YES];
[layer2 setCornerRadius:_btUp.frame.size.height / 2.0 - 1];
// table view
UIImageView *ivHeader = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, _tvAlbumList.frame.size.width, 0.5)];
ivHeader.backgroundColor = DO_ALBUM_NAME_TEXT_COLOR;
_tvAlbumList.tableHeaderView = ivHeader;
UIImageView *ivFooter = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, _tvAlbumList.frame.size.width, 0.5)];
ivFooter.backgroundColor = DO_ALBUM_NAME_TEXT_COLOR;
_tvAlbumList.tableFooterView = ivFooter;
// dimmed view
_vDimmed.alpha = 0.0;
_vDimmed.frame = self.view.frame;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTapOnDimmedView:)];
[_vDimmed addGestureRecognizer:tap];
}
- (void)readAlbumList
{
[ASSETHELPER getGroupList:^(NSArray *aGroups) {
[_tvAlbumList reloadData];
[_tvAlbumList selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];
[_btSelectAlbum setTitle:[ASSETHELPER getGroupInfo:0][@"name"] forState:UIControlStateNormal];
[self showPhotosInGroup:0];
if (aGroups.count == 1)
_btSelectAlbum.enabled = NO;
// calculate tableview's height
_tvAlbumList.frame = CGRectMake(_tvAlbumList.frame.origin.x, _tvAlbumList.frame.origin.y, _tvAlbumList.frame.size.width, MIN(aGroups.count * 50, 200));
}];
}
#pragma mark - for bottom menu
- (void)initBottomMenu
{
_vBottomMenu.backgroundColor = DO_MENU_BACK_COLOR;
[_btSelectAlbum setTitleColor:DO_BOTTOM_TEXT_COLOR forState:UIControlStateNormal];
[_btSelectAlbum setTitleColor:DO_BOTTOM_TEXT_COLOR forState:UIControlStateDisabled];
_ivLine1.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"line.png"]];
_ivLine2.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"line.png"]];
if (_nMaxCount == DO_NO_LIMIT_SELECT)
{
_lbSelectCount.text = @"(0)";
_lbSelectCount.textColor = DO_BOTTOM_TEXT_COLOR;
}
else if (_nMaxCount <= 1)
{
// hide ok button
_btOK.hidden = YES;
_ivLine1.hidden = YES;
CGRect rect = _btSelectAlbum.frame;
rect.size.width = rect.size.width + 60;
_btSelectAlbum.frame = rect;
_lbSelectCount.hidden = YES;
}
else
{
_lbSelectCount.text = [NSString stringWithFormat:@"(0/%d)", (int)_nMaxCount];
_lbSelectCount.textColor = DO_BOTTOM_TEXT_COLOR;
}
}
- (IBAction)onSelectPhoto:(id)sender
{
NSMutableArray *aResult = [[NSMutableArray alloc] initWithCapacity:_dSelected.count];
NSArray *aKeys = [_dSelected keysSortedByValueUsingSelector:@selector(compare:)];
if (_nResultType == DO_PICKER_RESULT_UIIMAGE)
{
for (int i = 0; i < _dSelected.count; i++)
[aResult addObject:[ASSETHELPER getImageAtIndex:[aKeys[i] integerValue] type:ASSET_PHOTO_SCREEN_SIZE]];
}
else
{
for (int i = 0; i < _dSelected.count; i++)
[aResult addObject:[ASSETHELPER getAssetAtIndex:[aKeys[i] integerValue]]];
}
[_delegate didSelectPhotosFromDoImagePickerController:self result:aResult];
}
- (IBAction)onCancel:(id)sender
{
NSLog(@"keys : %@", _dSelected.allKeys );
NSLog(@"values : %@", _dSelected);
[_delegate didCancelDoImagePickerController];
}
- (IBAction)onSelectAlbum:(id)sender
{
if (_tvAlbumList.frame.origin.y == _vBottomMenu.frame.origin.y)
{
// show tableview
[UIView animateWithDuration:0.2 animations:^(void) {
_vDimmed.alpha = 0.7;
_tvAlbumList.frame = CGRectMake(0, _vBottomMenu.frame.origin.y - _tvAlbumList.frame.size.height,
_tvAlbumList.frame.size.width, _tvAlbumList.frame.size.height);
_tvAlbumList.alpha = 1.0;
_ivShowMark.transform = CGAffineTransformMakeRotation(M_PI);
}];
}
else
{
// hide tableview
[self hideBottomMenu];
}
}
#pragma mark - for side buttons
- (void)onTapOnDimmedView:(UITapGestureRecognizer *)tap
{
if (tap.state == UIGestureRecognizerStateEnded)
{
[self hideBottomMenu];
if (_ivPreview != nil)
[self hidePreview];
}
}
- (IBAction)onUp:(id)sender
{
[_cvPhotoList scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
}
- (IBAction)onDown:(id)sender
{
[_cvPhotoList scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:[ASSETHELPER getPhotoCountOfCurrentGroup] - 1 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
}
#pragma mark - UITableViewDelegate for selecting album
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [ASSETHELPER getGroupCount];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
DoAlbumCell *cell = (DoAlbumCell*)[tableView dequeueReusableCellWithIdentifier:@"DoAlbumCell"];
if (cell == nil)
{
cell = [[[NSBundle mainBundle] loadNibNamed:@"DoAlbumCell" owner:nil options:nil] lastObject];
}
NSDictionary *d = [ASSETHELPER getGroupInfo:indexPath.row];
cell.lbAlbumName.text = d[@"name"];
cell.lbCount.text = [NSString stringWithFormat:@"%@", d[@"count"]];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self showPhotosInGroup:indexPath.row];
[_btSelectAlbum setTitle:[ASSETHELPER getGroupInfo:indexPath.row][@"name"] forState:UIControlStateNormal];
[self hideBottomMenu];
}
- (void)hideBottomMenu
{
[UIView animateWithDuration:0.2 animations:^(void) {
_vDimmed.alpha = 0.0;
_tvAlbumList.frame = CGRectMake(0, _vBottomMenu.frame.origin.y, _tvAlbumList.frame.size.width, _tvAlbumList.frame.size.height);
_ivShowMark.transform = CGAffineTransformMakeRotation(0);
[UIView setAnimationDelay:0.1];
_tvAlbumList.alpha = 0.0;
}];
}
#pragma mark - UICollectionViewDelegates for photos
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [ASSETHELPER getPhotoCountOfCurrentGroup];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
DoPhotoCell *cell = (DoPhotoCell *)[_cvPhotoList dequeueReusableCellWithReuseIdentifier:@"DoPhotoCell" forIndexPath:indexPath];
cell.ivPhoto.image = [ASSETHELPER getImageAtIndex:indexPath.row type:ASSET_PHOTO_THUMBNAIL];
if (_dSelected[@(indexPath.row)] == nil)
[cell setSelectMode:NO];
else
[cell setSelectMode:YES];
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (_nMaxCount > 1 || _nMaxCount == DO_NO_LIMIT_SELECT)
{
DoPhotoCell *cell = (DoPhotoCell *)[collectionView cellForItemAtIndexPath:indexPath];
if ((_dSelected[@(indexPath.row)] == nil) && (_nMaxCount > _dSelected.count))
{
// select
_dSelected[@(indexPath.row)] = @(_dSelected.count);
[cell setSelectMode:YES];
}
else
{
// unselect
[_dSelected removeObjectForKey:@(indexPath.row)];
[cell setSelectMode:NO];
}
if (_nMaxCount == DO_NO_LIMIT_SELECT)
_lbSelectCount.text = [NSString stringWithFormat:@"(%d)", (int)_dSelected.count];
else
_lbSelectCount.text = [NSString stringWithFormat:@"(%d/%d)", (int)_dSelected.count, (int)_nMaxCount];
}
else
{
if (_nResultType == DO_PICKER_RESULT_UIIMAGE)
[_delegate didSelectPhotosFromDoImagePickerController:self result:@[[ASSETHELPER getImageAtIndex:indexPath.row type:ASSET_PHOTO_SCREEN_SIZE]]];
else
[_delegate didSelectPhotosFromDoImagePickerController:self result:@[[ASSETHELPER getAssetAtIndex:indexPath.row]]];
}
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (_nColumnCount == 2)
return CGSizeMake(158, 158);
else if (_nColumnCount == 3)
return CGSizeMake(104, 104);
else if (_nColumnCount == 4)
return CGSizeMake(77, 77);
return CGSizeZero;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView == _cvPhotoList)
{
[UIView animateWithDuration:0.2 animations:^(void) {
if (scrollView.contentOffset.y <= 50)
_btUp.alpha = 0.0;
else
_btUp.alpha = 1.0;
if (scrollView.contentOffset.y + scrollView.frame.size.height >= scrollView.contentSize.height)
_btDown.alpha = 0.0;
else
_btDown.alpha = 1.0;
}];
}
}
// for multiple selection with panning
- (void)onPanForSelection:(UIPanGestureRecognizer *)gestureRecognizer
{
if (_ivPreview != nil)
return;
double fX = [gestureRecognizer locationInView:_cvPhotoList].x;
double fY = [gestureRecognizer locationInView:_cvPhotoList].y;
for (UICollectionViewCell *cell in _cvPhotoList.visibleCells)
{
float fSX = cell.frame.origin.x;
float fEX = cell.frame.origin.x + cell.frame.size.width;
float fSY = cell.frame.origin.y;
float fEY = cell.frame.origin.y + cell.frame.size.height;
if (fX >= fSX && fX <= fEX && fY >= fSY && fY <= fEY)
{
NSIndexPath *indexPath = [_cvPhotoList indexPathForCell:cell];
if (_lastAccessed != indexPath)
{
[self collectionView:_cvPhotoList didSelectItemAtIndexPath:indexPath];
}
_lastAccessed = indexPath;
}
}
if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
{
_lastAccessed = nil;
_cvPhotoList.scrollEnabled = YES;
}
}
// for preview
- (void)onLongTapForPreview:(UILongPressGestureRecognizer *)gestureRecognizer
{
if (_ivPreview != nil)
return;
if (gestureRecognizer.state == UIGestureRecognizerStateBegan)
{
double fX = [gestureRecognizer locationInView:_cvPhotoList].x;
double fY = [gestureRecognizer locationInView:_cvPhotoList].y;
NSIndexPath *indexPath = nil;
for (UICollectionViewCell *cell in _cvPhotoList.visibleCells)
{
float fSX = cell.frame.origin.x;
float fEX = cell.frame.origin.x + cell.frame.size.width;
float fSY = cell.frame.origin.y;
float fEY = cell.frame.origin.y + cell.frame.size.height;
if (fX >= fSX && fX <= fEX && fY >= fSY && fY <= fEY)
{
indexPath = [_cvPhotoList indexPathForCell:cell];
break;
}
}
if (indexPath != nil)
[self showPreview:indexPath.row];
}
}
#pragma mark - for photos
- (void)showPhotosInGroup:(NSInteger)nIndex
{
if (_nMaxCount == DO_NO_LIMIT_SELECT)
{
_dSelected = [[NSMutableDictionary alloc] init];
_lbSelectCount.text = @"(0)";
}
else if (_nMaxCount > 1)
{
_dSelected = [[NSMutableDictionary alloc] initWithCapacity:_nMaxCount];
_lbSelectCount.text = [NSString stringWithFormat:@"(0/%d)", (int)_nMaxCount];
}
[ASSETHELPER getPhotoListOfGroupByIndex:nIndex result:^(NSArray *aPhotos) {
[_cvPhotoList reloadData];
_cvPhotoList.alpha = 0.3;
[UIView animateWithDuration:0.2 animations:^(void) {
[UIView setAnimationDelay:0.1];
_cvPhotoList.alpha = 1.0;
}];
if (aPhotos.count > 0)
{
[_cvPhotoList scrollToItemAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionTop animated:NO];
}
_btUp.alpha = 0.0;
dispatch_async(dispatch_get_main_queue(), ^(void) {
if (_cvPhotoList.contentSize.height < _cvPhotoList.frame.size.height)
_btDown.alpha = 0.0;
else
_btDown.alpha = 1.0;
});
}];
}
- (void)showPreview:(NSInteger)nIndex
{
[self.view bringSubviewToFront:_vDimmed];
_ivPreview = [[UIImageView alloc] initWithFrame:_vDimmed.frame];
_ivPreview.contentMode = UIViewContentModeScaleAspectFit;
_ivPreview.autoresizingMask = _vDimmed.autoresizingMask;
[_vDimmed addSubview:_ivPreview];
_ivPreview.image = [ASSETHELPER getImageAtIndex:nIndex type:ASSET_PHOTO_SCREEN_SIZE];
// add gesture for close preview
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onPanToClosePreview:)];
[_vDimmed addGestureRecognizer:pan];
[UIView animateWithDuration:0.2 animations:^(void) {
_vDimmed.alpha = 1.0;
}];
}
- (void)hidePreview
{
[self.view bringSubviewToFront:_tvAlbumList];
[self.view bringSubviewToFront:_vBottomMenu];
[_ivPreview removeFromSuperview];
_ivPreview = nil;
_vDimmed.alpha = 0.0;
[_vDimmed removeGestureRecognizer:[_vDimmed.gestureRecognizers lastObject]];
}
- (void)onPanToClosePreview:(UIPanGestureRecognizer *)gestureRecognizer
{
CGPoint translation = [gestureRecognizer translationInView:self.view];
if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
{
[UIView animateWithDuration:0.2 animations:^(void) {
if (_vDimmed.alpha < 0.7) // close preview
{
CGPoint pt = _ivPreview.center;
if (_ivPreview.center.y > _vDimmed.center.y)
pt.y = self.view.frame.size.height * 1.5;
else if (_ivPreview.center.y < _vDimmed.center.y)
pt.y = -self.view.frame.size.height * 1.5;
_ivPreview.center = pt;
[self hidePreview];
}
else
{
_vDimmed.alpha = 1.0;
_ivPreview.center = _vDimmed.center;
}
}];
}
else
{
_ivPreview.center = CGPointMake(_ivPreview.center.x, _ivPreview.center.y + translation.y);
[gestureRecognizer setTranslation:CGPointMake(0, 0) inView:self.view];
_vDimmed.alpha = 1 - ABS(_ivPreview.center.y - _vDimmed.center.y) / (self.view.frame.size.height / 2.0);
}
}
#pragma mark - Others
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}
@end
+153
View File
@@ -0,0 +1,153 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3746"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="DoImagePickerController">
<connections>
<outlet property="btDown" destination="cGZ-TM-6a7" id="Ri3-nT-eeS"/>
<outlet property="btOK" destination="Glg-hT-Yyl" id="9Qb-xj-IVR"/>
<outlet property="btSelectAlbum" destination="JCk-XP-hr7" id="bxX-t8-H83"/>
<outlet property="btUp" destination="j0i-qC-Y6W" id="THy-66-3pz"/>
<outlet property="cvPhotoList" destination="NWT-KZ-ZEa" id="vFa-3T-m01"/>
<outlet property="ivLine1" destination="vxs-FJ-4CL" id="QNZ-ca-0hn"/>
<outlet property="ivLine2" destination="xuh-QZ-xfS" id="Aeb-Qv-q0r"/>
<outlet property="ivShowMark" destination="8Ub-UN-kF9" id="axP-ER-qRJ"/>
<outlet property="lbSelectCount" destination="Aes-5e-n0s" id="ab4-Gj-S8q"/>
<outlet property="tvAlbumList" destination="OuM-nH-WaU" id="icz-iC-8hb"/>
<outlet property="vBottomMenu" destination="m70-sa-NHK" id="eu7-UE-Y2p"/>
<outlet property="vDimmed" destination="v5R-jm-nVL" id="x82-tL-iti"/>
<outlet property="view" destination="1" id="3"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="1">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<collectionView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" minimumZoomScale="0.0" maximumZoomScale="0.0" dataMode="none" id="NWT-KZ-ZEa">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<inset key="contentInset" minX="0.0" minY="0.0" maxX="0.0" maxY="52"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="4" minimumInteritemSpacing="4" id="5bk-ia-oRG">
<size key="itemSize" width="104" height="104"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
<cells/>
<connections>
<outlet property="dataSource" destination="-1" id="Tpn-xE-pG2"/>
<outlet property="delegate" destination="-1" id="HH1-75-IBr"/>
</connections>
</collectionView>
<button opaque="NO" alpha="0.0" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="j0i-qC-Y6W">
<rect key="frame" x="270" y="10" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<state key="normal" image="up.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onUp:" destination="-1" eventType="touchUpInside" id="nzJ-SE-iEC"/>
</connections>
</button>
<button opaque="NO" alpha="0.0" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="cGZ-TM-6a7">
<rect key="frame" x="270" y="468" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<state key="normal" image="down.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onDown:" destination="-1" eventType="touchUpInside" id="glY-XH-qPw"/>
</connections>
</button>
<view alpha="0.69999999999999996" contentMode="scaleToFill" id="v5R-jm-nVL" userLabel="View : dimmed layer">
<rect key="frame" x="0.0" y="0.0" width="320" height="109"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="50" sectionHeaderHeight="22" sectionFooterHeight="22" id="OuM-nH-WaU">
<rect key="frame" x="0.0" y="428" width="320" height="140"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" white="1" alpha="0.95000000000000007" colorSpace="calibratedWhite"/>
<connections>
<outlet property="dataSource" destination="-1" id="ahk-Yc-o1b"/>
<outlet property="delegate" destination="-1" id="QSU-Wr-tVd"/>
</connections>
</tableView>
<view contentMode="scaleToFill" id="m70-sa-NHK">
<rect key="frame" x="0.0" y="518" width="320" height="50"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="Glg-hT-Yyl">
<rect key="frame" x="200" y="0.0" width="60" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<state key="normal" image="check.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onSelectPhoto:" destination="-1" eventType="touchUpInside" id="s6N-uq-WnE"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="qxx-TK-ubw">
<rect key="frame" x="260" y="0.0" width="60" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<state key="normal" image="close.png">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onCancel:" destination="-1" eventType="touchUpInside" id="4pw-F9-77N"/>
</connections>
</button>
<imageView userInteractionEnabled="NO" alpha="0.29999999999999999" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="vxs-FJ-4CL">
<rect key="frame" x="200" y="0.0" width="1" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</imageView>
<imageView userInteractionEnabled="NO" alpha="0.29999999999999999" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="xuh-QZ-xfS">
<rect key="frame" x="260" y="0.0" width="1" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="JCk-XP-hr7">
<rect key="frame" x="0.0" y="0.0" width="200" height="50"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Avenir-Medium" family="Avenir" pointSize="16"/>
<inset key="contentEdgeInsets" minX="20" minY="0.0" maxX="0.0" maxY="0.0"/>
<state key="normal" title="Button">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onSelectAlbum:" destination="-1" eventType="touchUpInside" id="tFY-31-UXF"/>
</connections>
</button>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0/4" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Aes-5e-n0s">
<rect key="frame" x="152" y="15" width="42" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="Avenir-Light" family="Avenir" pointSize="13"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="show.png" id="8Ub-UN-kF9">
<rect key="frame" x="6" y="21" width="10" height="8"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
</subviews>
<color key="backgroundColor" red="0.94117653369999998" green="0.7254902124" blue="0.40392160420000001" alpha="0.5" colorSpace="deviceRGB"/>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</view>
</objects>
<resources>
<image name="check.png" width="20" height="20"/>
<image name="close.png" width="20" height="20"/>
<image name="down.png" width="20" height="20"/>
<image name="show.png" width="10" height="8"/>
<image name="up.png" width="20" height="20"/>
</resources>
</document>
+17
View File
@@ -0,0 +1,17 @@
//
// DoPhotoCell.h
// DoImagePickerController
//
// Created by Donobono on 2014. 1. 23..
//
#import <UIKit/UIKit.h>
@interface DoPhotoCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *ivPhoto;
@property (weak, nonatomic) IBOutlet UIView *vSelect;
- (void)setSelectMode:(BOOL)bSelect;
@end
+38
View File
@@ -0,0 +1,38 @@
//
// DoPhotoCell.m
// DoImagePickerController
//
// Created by Donobono on 2014. 1. 23..
//
#import "DoPhotoCell.h"
@implementation DoPhotoCell
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelectMode:(BOOL)bSelect
{
if (bSelect)
_ivPhoto.alpha = 0.2;
else
_ivPhoto.alpha = 1.0;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
+28
View File
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3747"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="tQc-RH-ngT" customClass="DoPhotoCell">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="Aw4-DJ-VAP">
<rect key="frame" x="0.0" y="0.0" width="104" height="104"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</imageView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="ivPhoto" destination="Aw4-DJ-VAP" id="eAf-34-YAD"/>
</connections>
</collectionViewCell>
</objects>
</document>
+8
View File
@@ -0,0 +1,8 @@
platform :ios, '7.0'
pod 'Reachability'
pod 'SBJson'
pod 'SDWebImage'
pod 'MKNetworkKit'
pod 'DTCoreText'
+5
View File
@@ -0,0 +1,5 @@
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers" "${PODS_ROOT}/Headers/DTCoreText" "${PODS_ROOT}/Headers/DTFoundation" "${PODS_ROOT}/Headers/MKNetworkKit" "${PODS_ROOT}/Headers/MKNetworkKit/Categories" "${PODS_ROOT}/Headers/Reachability" "${PODS_ROOT}/Headers/SBJson" "${PODS_ROOT}/Headers/SDWebImage" "$(SDKROOT)/usr/include/libxml2"
OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers" -isystem "${PODS_ROOT}/Headers/DTCoreText" -isystem "${PODS_ROOT}/Headers/DTFoundation" -isystem "${PODS_ROOT}/Headers/MKNetworkKit" -isystem "${PODS_ROOT}/Headers/MKNetworkKit/Categories" -isystem "${PODS_ROOT}/Headers/Reachability" -isystem "${PODS_ROOT}/Headers/SBJson" -isystem "${PODS_ROOT}/Headers/SDWebImage"
OTHER_LDFLAGS = -ObjC -lxml2 -framework CFNetwork -framework CoreGraphics -framework CoreText -framework ImageIO -framework MediaPlayer -framework QuartzCore -framework Security -framework SystemConfiguration
PODS_ROOT = ${SRCROOT}/Pods
+9371
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0E99819739AC47ABA7FA492B"
BuildableName = "libPods-Reachability.a"
BlueprintName = "Pods-Reachability"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E9B6674D0519400D8E9E238A"
BuildableName = "libPods-SBJson.a"
BlueprintName = "Pods-SBJson"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "911FBED90C744921BBA741B8"
BuildableName = "libPods-SDWebImage.a"
BlueprintName = "Pods-SDWebImage"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C98B7D50DC474B978299407B"
BuildableName = "libPods.a"
BlueprintName = "Pods"
ReferencedContainer = "container:Pods.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Pods-DTCoreText.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>Pods-DTFoundation.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>Pods-MKNetworkKit.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>Pods-Reachability.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>Pods-SBJson.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>Pods-SDWebImage.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
<key>Pods.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>0E99819739AC47ABA7FA492B</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>31DC683E7A6647F99E51FDF8</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>911FBED90C744921BBA741B8</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>B3EC766BC8404753A0CDA0A5</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>C98B7D50DC474B978299407B</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>E91BD44DF6524EF182815260</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>E9B6674D0519400D8E9E238A</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
+109
View File
@@ -0,0 +1,109 @@
/*
Copyright (c) 2011, Tony Million.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <sys/socket.h>
#import <netinet/in.h>
#import <netinet6/in6.h>
#import <arpa/inet.h>
#import <ifaddrs.h>
#import <netdb.h>
/**
* Does ARC support GCD objects?
* It does if the minimum deployment target is iOS 6+ or Mac OS X 8+
*
* @see http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
**/
#if OS_OBJECT_USE_OBJC
#define NEEDS_DISPATCH_RETAIN_RELEASE 0
#else
#define NEEDS_DISPATCH_RETAIN_RELEASE 1
#endif
/**
* Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X.
*
* @see http://nshipster.com/ns_enum-ns_options/
**/
#ifndef NS_ENUM
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
#endif
extern NSString *const kReachabilityChangedNotification;
typedef NS_ENUM(NSInteger, NetworkStatus) {
// Apple NetworkStatus Compatible Names.
NotReachable = 0,
ReachableViaWiFi = 2,
ReachableViaWWAN = 1
};
@class Reachability;
typedef void (^NetworkReachable)(Reachability * reachability);
typedef void (^NetworkUnreachable)(Reachability * reachability);
@interface Reachability : NSObject
@property (nonatomic, copy) NetworkReachable reachableBlock;
@property (nonatomic, copy) NetworkUnreachable unreachableBlock;
@property (nonatomic, assign) BOOL reachableOnWWAN;
+(Reachability*)reachabilityWithHostname:(NSString*)hostname;
+(Reachability*)reachabilityForInternetConnection;
+(Reachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
+(Reachability*)reachabilityForLocalWiFi;
-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
-(BOOL)startNotifier;
-(void)stopNotifier;
-(BOOL)isReachable;
-(BOOL)isReachableViaWWAN;
-(BOOL)isReachableViaWiFi;
// WWAN may be available, but not active until a connection has been established.
// WiFi may require a connection for VPN on Demand.
-(BOOL)isConnectionRequired; // Identical DDG variant.
-(BOOL)connectionRequired; // Apple's routine.
// Dynamic, on demand connection?
-(BOOL)isConnectionOnDemand;
// Is user intervention required?
-(BOOL)isInterventionRequired;
-(NetworkStatus)currentReachabilityStatus;
-(SCNetworkReachabilityFlags)reachabilityFlags;
-(NSString*)currentReachabilityString;
-(NSString*)currentReachabilityFlags;
@end
+527
View File
@@ -0,0 +1,527 @@
/*
Copyright (c) 2011, Tony Million.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#import "Reachability.h"
NSString *const kReachabilityChangedNotification = @"kReachabilityChangedNotification";
@interface Reachability ()
@property (nonatomic, assign) SCNetworkReachabilityRef reachabilityRef;
#if NEEDS_DISPATCH_RETAIN_RELEASE
@property (nonatomic, assign) dispatch_queue_t reachabilitySerialQueue;
#else
@property (nonatomic, strong) dispatch_queue_t reachabilitySerialQueue;
#endif
@property (nonatomic, strong) id reachabilityObject;
-(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags;
-(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags;
@end
static NSString *reachabilityFlags(SCNetworkReachabilityFlags flags)
{
return [NSString stringWithFormat:@"%c%c %c%c%c%c%c%c%c",
#if TARGET_OS_IPHONE
(flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-',
#else
'X',
#endif
(flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-',
(flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-',
(flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-',
(flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
(flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-',
(flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-',
(flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-',
(flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-'];
}
// Start listening for reachability notifications on the current run loop
static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
{
#pragma unused (target)
#if __has_feature(objc_arc)
Reachability *reachability = ((__bridge Reachability*)info);
#else
Reachability *reachability = ((Reachability*)info);
#endif
// We probably don't need an autoreleasepool here, as GCD docs state each queue has its own autorelease pool,
// but what the heck eh?
@autoreleasepool
{
[reachability reachabilityChanged:flags];
}
}
@implementation Reachability
@synthesize reachabilityRef;
@synthesize reachabilitySerialQueue;
@synthesize reachableOnWWAN;
@synthesize reachableBlock;
@synthesize unreachableBlock;
@synthesize reachabilityObject;
#pragma mark - Class Constructor Methods
+(Reachability*)reachabilityWithHostName:(NSString*)hostname
{
return [Reachability reachabilityWithHostname:hostname];
}
+(Reachability*)reachabilityWithHostname:(NSString*)hostname
{
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]);
if (ref)
{
id reachability = [[self alloc] initWithReachabilityRef:ref];
#if __has_feature(objc_arc)
return reachability;
#else
return [reachability autorelease];
#endif
}
return nil;
}
+(Reachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress
{
SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
if (ref)
{
id reachability = [[self alloc] initWithReachabilityRef:ref];
#if __has_feature(objc_arc)
return reachability;
#else
return [reachability autorelease];
#endif
}
return nil;
}
+(Reachability *)reachabilityForInternetConnection
{
struct sockaddr_in zeroAddress;
bzero(&zeroAddress, sizeof(zeroAddress));
zeroAddress.sin_len = sizeof(zeroAddress);
zeroAddress.sin_family = AF_INET;
return [self reachabilityWithAddress:&zeroAddress];
}
+(Reachability*)reachabilityForLocalWiFi
{
struct sockaddr_in localWifiAddress;
bzero(&localWifiAddress, sizeof(localWifiAddress));
localWifiAddress.sin_len = sizeof(localWifiAddress);
localWifiAddress.sin_family = AF_INET;
// IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
return [self reachabilityWithAddress:&localWifiAddress];
}
// Initialization methods
-(Reachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref
{
self = [super init];
if (self != nil)
{
self.reachableOnWWAN = YES;
self.reachabilityRef = ref;
}
return self;
}
-(void)dealloc
{
[self stopNotifier];
if(self.reachabilityRef)
{
CFRelease(self.reachabilityRef);
self.reachabilityRef = nil;
}
self.reachableBlock = nil;
self.unreachableBlock = nil;
#if !(__has_feature(objc_arc))
[super dealloc];
#endif
}
#pragma mark - Notifier Methods
// Notifier
// NOTE: This uses GCD to trigger the blocks - they *WILL NOT* be called on THE MAIN THREAD
// - In other words DO NOT DO ANY UI UPDATES IN THE BLOCKS.
// INSTEAD USE dispatch_async(dispatch_get_main_queue(), ^{UISTUFF}) (or dispatch_sync if you want)
-(BOOL)startNotifier
{
SCNetworkReachabilityContext context = { 0, NULL, NULL, NULL, NULL };
// this should do a retain on ourself, so as long as we're in notifier mode we shouldn't disappear out from under ourselves
// woah
self.reachabilityObject = self;
// First, we need to create a serial queue.
// We allocate this once for the lifetime of the notifier.
self.reachabilitySerialQueue = dispatch_queue_create("com.tonymillion.reachability", NULL);
if(!self.reachabilitySerialQueue)
{
return NO;
}
#if __has_feature(objc_arc)
context.info = (__bridge void *)self;
#else
context.info = (void *)self;
#endif
if (!SCNetworkReachabilitySetCallback(self.reachabilityRef, TMReachabilityCallback, &context))
{
#ifdef DEBUG
NSLog(@"SCNetworkReachabilitySetCallback() failed: %s", SCErrorString(SCError()));
#endif
// Clear out the dispatch queue
if(self.reachabilitySerialQueue)
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(self.reachabilitySerialQueue);
#endif
self.reachabilitySerialQueue = nil;
}
self.reachabilityObject = nil;
return NO;
}
// Set it as our reachability queue, which will retain the queue
if(!SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, self.reachabilitySerialQueue))
{
#ifdef DEBUG
NSLog(@"SCNetworkReachabilitySetDispatchQueue() failed: %s", SCErrorString(SCError()));
#endif
// UH OH - FAILURE!
// First stop, any callbacks!
SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
// Then clear out the dispatch queue.
if(self.reachabilitySerialQueue)
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(self.reachabilitySerialQueue);
#endif
self.reachabilitySerialQueue = nil;
}
self.reachabilityObject = nil;
return NO;
}
return YES;
}
-(void)stopNotifier
{
// First stop, any callbacks!
SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL);
// Unregister target from the GCD serial dispatch queue.
SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, NULL);
if(self.reachabilitySerialQueue)
{
#if NEEDS_DISPATCH_RETAIN_RELEASE
dispatch_release(self.reachabilitySerialQueue);
#endif
self.reachabilitySerialQueue = nil;
}
self.reachabilityObject = nil;
}
#pragma mark - reachability tests
// This is for the case where you flick the airplane mode;
// you end up getting something like this:
//Reachability: WR ct-----
//Reachability: -- -------
//Reachability: WR ct-----
//Reachability: -- -------
// We treat this as 4 UNREACHABLE triggers - really apple should do better than this
#define testcase (kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsTransientConnection)
-(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags
{
BOOL connectionUP = YES;
if(!(flags & kSCNetworkReachabilityFlagsReachable))
connectionUP = NO;
if( (flags & testcase) == testcase )
connectionUP = NO;
#if TARGET_OS_IPHONE
if(flags & kSCNetworkReachabilityFlagsIsWWAN)
{
// We're on 3G.
if(!self.reachableOnWWAN)
{
// We don't want to connect when on 3G.
connectionUP = NO;
}
}
#endif
return connectionUP;
}
-(BOOL)isReachable
{
SCNetworkReachabilityFlags flags;
if(!SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
return NO;
return [self isReachableWithFlags:flags];
}
-(BOOL)isReachableViaWWAN
{
#if TARGET_OS_IPHONE
SCNetworkReachabilityFlags flags = 0;
if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
// Check we're REACHABLE
if(flags & kSCNetworkReachabilityFlagsReachable)
{
// Now, check we're on WWAN
if(flags & kSCNetworkReachabilityFlagsIsWWAN)
{
return YES;
}
}
}
#endif
return NO;
}
-(BOOL)isReachableViaWiFi
{
SCNetworkReachabilityFlags flags = 0;
if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
// Check we're reachable
if((flags & kSCNetworkReachabilityFlagsReachable))
{
#if TARGET_OS_IPHONE
// Check we're NOT on WWAN
if((flags & kSCNetworkReachabilityFlagsIsWWAN))
{
return NO;
}
#endif
return YES;
}
}
return NO;
}
// WWAN may be available, but not active until a connection has been established.
// WiFi may require a connection for VPN on Demand.
-(BOOL)isConnectionRequired
{
return [self connectionRequired];
}
-(BOOL)connectionRequired
{
SCNetworkReachabilityFlags flags;
if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
}
return NO;
}
// Dynamic, on demand connection?
-(BOOL)isConnectionOnDemand
{
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) &&
(flags & (kSCNetworkReachabilityFlagsConnectionOnTraffic | kSCNetworkReachabilityFlagsConnectionOnDemand)));
}
return NO;
}
// Is user intervention required?
-(BOOL)isInterventionRequired
{
SCNetworkReachabilityFlags flags;
if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) &&
(flags & kSCNetworkReachabilityFlagsInterventionRequired));
}
return NO;
}
#pragma mark - reachability status stuff
-(NetworkStatus)currentReachabilityStatus
{
if([self isReachable])
{
if([self isReachableViaWiFi])
return ReachableViaWiFi;
#if TARGET_OS_IPHONE
return ReachableViaWWAN;
#endif
}
return NotReachable;
}
-(SCNetworkReachabilityFlags)reachabilityFlags
{
SCNetworkReachabilityFlags flags = 0;
if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
{
return flags;
}
return 0;
}
-(NSString*)currentReachabilityString
{
NetworkStatus temp = [self currentReachabilityStatus];
if(temp == reachableOnWWAN)
{
// Updated for the fact that we have CDMA phones now!
return NSLocalizedString(@"Cellular", @"");
}
if (temp == ReachableViaWiFi)
{
return NSLocalizedString(@"WiFi", @"");
}
return NSLocalizedString(@"No Connection", @"");
}
-(NSString*)currentReachabilityFlags
{
return reachabilityFlags([self reachabilityFlags]);
}
#pragma mark - Callback function calls this method
-(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags
{
if([self isReachableWithFlags:flags])
{
if(self.reachableBlock)
{
self.reachableBlock(self);
}
}
else
{
if(self.unreachableBlock)
{
self.unreachableBlock(self);
}
}
// this makes sure the change notification happens on the MAIN THREAD
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification
object:self];
});
}
#pragma mark - Debug Description
- (NSString *) description;
{
NSString *description = [NSString stringWithFormat:@"<%@: %#x>",
NSStringFromClass([self class]), (unsigned int) self];
return description;
}
@end
+35
View File
@@ -0,0 +1,35 @@
/*
Copyright (C) 2009-2011 Stig Brautaset. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import "SBJson4Writer.h"
#import "SBJson4StreamParser.h"
#import "SBJson4Parser.h"
#import "SBJson4StreamWriter.h"
#import "SBJson4StreamTokeniser.h"