iOS项目中几个常用的图片常用地基处理方法法

&nbsp>&nbsp
&nbsp>&nbsp
&nbsp>&nbsp
iOS------自动查找项目中不用的图片资源
摘要:注意:删除的时候要谨慎!别什么图都删了,看看对项目有没有作用。这个插件有时也会有一定的误差。具体操作步骤:1.去github上下载LSUnusedResources(下载地址:https://github.com/tinymind/LSUnusedResources/)2.运行LSUnusedResources项目,运行结果如下图3.将项目路径拖入到此框内4.点击search查找没有使用的图片资源&找到后&然后删除
注意:删除的时候要谨慎!别什么图都删了,看看对项目有没有作用。这个插件有时也会有一定的误差。
具体操作步骤:
1.去github上下载LSUnusedResources(下载地址:https://github.com/tinymind/LSUnusedResources/)
2.运行LSUnusedResources项目,运行结果如下图
3.将项目路径拖入到此框内
4.点击search查找没有使用的图片资源 &找到后 &然后删除
以上是的内容,更多
的内容,请您使用右上方搜索功能获取相关信息。
若你要投稿、删除文章请联系邮箱:zixun-group@service.aliyun.com,工作人员会在五个工作日内给你回复。
云服务器 ECS
可弹性伸缩、安全稳定、简单易用
&40.8元/月起
预测未发生的攻击
&24元/月起
为您提供0门槛上云实践机会
你可能还喜欢
你可能感兴趣
阿里云教程中心为您免费提供
iOS------自动查找项目中不用的图片资源相关信息,包括
的信息,所有iOS------自动查找项目中不用的图片资源相关内容均不代表阿里云的意见!投稿删除文章请联系邮箱:zixun-group@service.aliyun.com,工作人员会在五个工作日内答复
售前咨询热线
支持与服务
资源和社区
关注阿里云
InternationalWhoops, looks like something went wrong.
QueryException in :
SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'php100ad'@'10.46.17.240' for table 'requirement' (SQL: select * from `requirement` where `id` = 53e07f5b4bac limit 1)
at Connection->runQueryCallback('select * from `requirement` where `id` = ? limit 1', array('53e07f5b4bac'), object(Closure)) in
at Connection->run('select * from `requirement` where `id` = ? limit 1', array('53e07f5b4bac'), object(Closure)) in
at Connection->select('select * from `requirement` where `id` = ? limit 1', array('53e07f5b4bac'), true) in
at Builder->runSelect() in
at Builder->get(array('*')) in
at Builder->getModels(array('*')) in
at Builder->get(array('*')) in
at Builder->first() in
at RequirementController->show('53e07f5b4bac')
at call_user_func_array(array(object(RequirementController), 'show'), array('id' => '53e07f5b4bac')) in
at Controller->callAction('show', array('id' => '53e07f5b4bac')) in
at ControllerDispatcher->call(object(RequirementController), object(Route), 'show') in
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->then(object(Closure)) in
at ControllerDispatcher->callWithinStack(object(RequirementController), object(Route), object(Request), 'show') in
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Frontend\RequirementController', 'show') in
at Route->runWithCustomDispatcher(object(Request)) in
at Route->run(object(Request)) in
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->then(object(Closure)) in
at Router->runRouteWithinStack(object(Route), object(Request)) in
at Router->dispatchToRoute(object(Request)) in
at Router->dispatch(object(Request)) in
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->then(object(Closure)) in
at Kernel->sendRequestThroughRouter(object(Request)) in
at Kernel->handle(object(Request)) in
PDOException in :
SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'php100ad'@'10.46.17.240' for table 'requirement'
at PDO->prepare('select * from `requirement` where `id` = ? limit 1') in
at Connection->Illuminate\Database\{closure}(object(MySqlConnection), 'select * from `requirement` where `id` = ? limit 1', array('53e07f5b4bac')) in
at Connection->runQueryCallback('select * from `requirement` where `id` = ? limit 1', array('53e07f5b4bac'), object(Closure)) in
at Connection->run('select * from `requirement` where `id` = ? limit 1', array('53e07f5b4bac'), object(Closure)) in
at Connection->select('select * from `requirement` where `id` = ? limit 1', array('53e07f5b4bac'), true) in
at Builder->runSelect() in
at Builder->get(array('*')) in
at Builder->getModels(array('*')) in
at Builder->get(array('*')) in
at Builder->first() in
at RequirementController->show('53e07f5b4bac')
at call_user_func_array(array(object(RequirementController), 'show'), array('id' => '53e07f5b4bac')) in
at Controller->callAction('show', array('id' => '53e07f5b4bac')) in
at ControllerDispatcher->call(object(RequirementController), object(Route), 'show') in
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->then(object(Closure)) in
at ControllerDispatcher->callWithinStack(object(RequirementController), object(Route), object(Request), 'show') in
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Frontend\RequirementController', 'show') in
at Route->runWithCustomDispatcher(object(Request)) in
at Route->run(object(Request)) in
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->then(object(Closure)) in
at Router->runRouteWithinStack(object(Route), object(Request)) in
at Router->dispatchToRoute(object(Request)) in
at Router->dispatch(object(Request)) in
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in
at Pipeline->then(object(Closure)) in
at Kernel->sendRequestThroughRouter(object(Request)) in
at Kernel->handle(object(Request)) in【iOS】利用runtime处理程序中的常见崩溃
一个已经发布到AppStore上的App,最忌讳的就是崩溃问题。为什么在开发阶段或者测试阶段都不会崩溃,而发布到AppStore上就崩溃了呢?究其根源,最主要的原因就是数据的错乱。特别是 服务器返回数据的错乱,将严重影响到我们的App。
Foundation框架存在许多潜在崩溃的危险
将 nil 插入可变数组中会导致崩溃。数组越界会导致崩溃。根据key给字典某个元素重新赋值时,若key为 nil 会导致崩溃。......
JQSafeKit简介
这个框架利用runtime技术对一些常用并且容易导致崩溃的方法进行处理,可以有效的防止崩溃。并且打印出具体是哪一行代码会导致崩溃,让你快速定位导致崩溃的代码。你可以获取到原本导致崩溃的主要信息&由于这个框架的存在,并不会崩溃&,进行相应的处理。比如:你可以将这些崩溃信息发送到自己服务器。你若集成了第三方崩溃日志收集的SDK,比如你用了腾讯的Bugly,你可以上报自定义异常。
下面先来看下防止崩溃的效果吧
可导致崩溃的代码
NSString *nilStr =
NSArray *array = @[@&HaRi&, nilStr];
若没有JQSafeKit来防止崩溃,则会直接崩溃,如下图
若有JQSafeKit来防止崩溃,则不会崩溃,并且会将原本会崩溃情况的详细信息打印出来,如下图
Installation【安装】
From CocoaPods【使用CocoaPods】
&JQSafeKit&
Manually【手动导入】
Drag all source files under floder JQSafeKit to your project.【将JQSafeKit文件夹中的所有源代码拽入项目中】
在AppDelegate的didFinishLaunchingWithOptions方法中添加如下代码,让JQSafeKit生效
//这句代码会让JQSafeKit生效,若没有如下代码,则JQSafeKit就不起作用
[JQSafeKit becomeEffective];
若你想要获取崩溃日志的所有详细信息,只需添加通知的监听,监听的通知名为:JQSafeKitNotification
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[JQSafeKit becomeEffective];
//监听通知:JQSafeKitNotification, 获取JQSafeKit捕获的崩溃日志的详细信息
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dealwithCrashMessage:) name:JQSafeKitNotification object:nil];
return YES;
- (void)dealwithCrashMessage:(NSNotification *)note {
//注意:所有的信息都在userInfo中
//你可以在这里收集相应的崩溃信息进行相应的处理(比如传到自己服务器)
NSLog(@&%@&,note.userInfo);
下面通过打断点的形式来看下userInfo中的信息结构,看下包含了哪些信息
再看下控制台输出日志来看下userInfo中的包含了哪些信息
目前可以防止崩溃的方法有
NSArray 1. NSArray的快速创建方式 NSArray *array = @[@&HaRi&, @&JQSafeKit&]; //这种创建方式其实调用的是2中的方法
2. +(instancetype)arrayWithObjects:(const id _Nonnull __unsafe_unretained *)objects count:(NSUInteger)cnt
3. - (id)objectAtIndex:(NSUInteger)index
NSMutableArray 1. - (id)objectAtIndex:(NSUInteger)index2. - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx3. - (void)removeObjectAtIndex:(NSUInteger)index4. - (void)insertObject:(id)anObject atIndex:(NSUInteger)index
NSDictionary1. NSDictionary的快速创建方式 NSDictionary *dict = @{@&frameWork& : @&JQSafeKit&}; //这种创建方式其实调用的是2中的方法2. +(instancetype)dictionaryWithObjects:(const id _Nonnull __unsafe_unretained *)objects forKeys:(const id _Nonnull __unsafe_unretained *)keys count:(NSUInteger)cnt
NSMutableDictionary1. - (void)setObject:(id)anObject forKey:(id)aKey2. - (void)removeObjectForKey:(id)aKey
NSString1. - (unichar)characterAtIndex:(NSUInteger)index2. - (NSString *)substringFromIndex:(NSUInteger)from3. - (NSString *)substringToIndex:(NSUInteger)to {4. - (NSString *)substringWithRange:(NSRange)range {5. - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement6. - (NSString *)stringByReplacingOccurrencesOfString:(NSString *)target withString:(NSString *)replacement options:(NSStringCompareOptions)options range:(NSRange)searchRange7. - (NSString *)stringByReplacingCharactersInRange:(NSRange)range withString:(NSString *)replacement
NSMutableString1. 由于NSMutableString是继承于NSString,所以这里和NSString有些同样的方法就不重复写了2. - (void)replaceCharactersInRange:(NSRange)range withString:(NSString *)aString3. - (void)insertString:(NSString *)aString atIndex:(NSUInteger)loc4. - (void)deleteCharactersInRange:(NSRange)range程序写累了,就来玩玩酷跑小游戏吧,嘿嘿。
雨松MOMO送你一首歌曲,嘿嘿。
IOS研究院之打开照相机与本地相册选择图片(六)
IOS研究院之打开照相机与本地相册选择图片(六)
围观95405次
编辑日期: 字体:
Hello 大家好 IOS的文章好久都木有更新了,今天更新一篇哈。 这篇文章主要学习如何在IOS程序中打开照相机与本地相册并且选择一张图片。还是老样子MOMO写了一个简单的测试程序,如下图所示 在本地相册中选择一张图片后,我们将他拷贝至沙盒当中,在客户端中将它的缩略图放在按钮旁边,这个结构其实和新浪微薄中选择图片后的效果一样。最终点击发送将按钮将图片2进制图片上传服务器。
下面我们仔细学习具体的细节。创建一个空的IOS项目,接着在创建一个ViewController。
AppDelegate.h 应用的代理类 这个没什么好说的就是直接打开刚刚创建的新ViewController。
#import &UIKit/UIKit.h&#import "TestViewController.h"&@interface AppDelegate : UIResponder &UIApplicationDelegate&&@property (strong, nonatomic) UIWindow *window;@property (strong, nonatomic) UINavigationController *navController;@property (strong, nonatomic) UIViewController *viewController;@end
AppDelegate.m 在这里就是打开我们创建的TestViewController
12345678910111213141516171819202122232425262728
#import "AppDelegate.h"&@implementation AppDelegate&@synthesize window = _window;@synthesize navController;@synthesize viewController;&- (void)dealloc{&&&&[_window release];&&&&[super dealloc];}&- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{&&&&self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];&&&&&self.window.backgroundColor = [UIColor whiteColor];&&&&self.viewController =&&[[TestViewController alloc]init];&&&&self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];&&&&[self.window addSubview:navController.view];&&&&&[self.window makeKeyAndVisible];&&&&return YES;}&@end
TestViewController.h 注意这里面引入了很多代理类。
1234567891011121314
#import &UIKit/UIKit.h&&@interface TestViewController : UIViewController&UITextViewDelegate,UIActionSheetDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate&{&&&&//输入框&&&&UITextView *_textEditor;&&&&&//下拉菜单&&&&UIActionSheet *myActionSheet;&&&&&//图片2进制路径&&&&NSString* filePath;}@end
TestViewController.m 请大家仔细看这个类, 所有的东西都写在了这里哈。
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
#import "TestViewController.h"&@interface TestViewController ()&@end&@implementation TestViewController&- (void)viewDidLoad{&&&&[super viewDidLoad];&&&&//导航栏标题 self.navigationItem.title = @"雨松MOMO输入框";&&&&&//导航栏按钮&&&&self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& initWithTitle: @"发送"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& style: UIBarButtonItemStyleDone&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& target: self&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& action: @selector(sendInfo)] autorelease];&&&&&//输入框显示区域&&&&_textEditor = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];&&&&//设置它的代理&&&&_textEditor.delegate = self;&&&&_textEditor.autoresizingMask = UIViewAutoresizingFlexibleWidth;&&&&_textEditor.keyboardType = UIKeyboardTypeDefault;&&&&_textEditor.font = [UIFont systemFontOfSize:20];&&&&_textEditor.text = @"请输入内容";&&&&&//默认软键盘是在触摸区域后才会打开&&&&//这里表示进入当前ViewController直接打开软键盘&&&&[_textEditor becomeFirstResponder];&&&&&//把输入框加在视图中&&&&[self.view addSubview:_textEditor];&&&&&//下方的图片按钮 点击后呼出菜单 打开摄像机 查找本地相册&&&&UIImage *image = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"camera" ofType:@"png"]];&&&&&UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];&&&&button.frame = CGRectMake(0, 120, image.size.width, image.size.height);&&&&&[button setImage:image forState:UIControlStateNormal];&&&&&[button addTarget:self action:@selector(openMenu) forControlEvents:UIControlEventTouchUpInside];&&&&&//把它也加在视图当中&&&&[self.view addSubview:button];&}&-(void)openMenu{&&&&//在这里呼出下方菜单按钮项&&&&myActionSheet = [[UIActionSheet alloc]&&&&&&&&&&&&&&&& initWithTitle:nil&&&&&&&&&&&&&&&& delegate:self&&&&&&&&&&&&&&&& cancelButtonTitle:@"取消"&&&&&&&&&&&&&&&& destructiveButtonTitle:nil&&&&&&&&&&&&&&&& otherButtonTitles: @"打开照相机", @"从手机相册获取",nil];&&&&&&&[myActionSheet showInView:self.view];&&&&[myActionSheet release];&&&&&}&- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ &&&&&//呼出的菜单按钮点击后的响应&&&&if (buttonIndex == myActionSheet.cancelButtonIndex)&&&&{&&&&&&&&NSLog(@"取消");&&&&}&&&&&switch (buttonIndex)&&&&{&&&&&&&&case 0:&&//打开照相机拍照&&&&&&&&&&&&[self takePhoto];&&&&&&&&&&&&break; &&&&&&&&&case 1:&&//打开本地相册&&&&&&&&&&&&[self LocalPhoto];&&&&&&&&&&&&break;&&&&}}&//开始拍照-(void)takePhoto{&&&&UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;&&&&if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])&&&&{&&&&&&&&UIImagePickerController *picker = [[UIImagePickerController alloc] init];&&&&&&&&picker.delegate = self;&&&&&&&&//设置拍照后的图片可被编辑&&&&&&&&picker.allowsEditing = YES;&&&&&&&&picker.sourceType = sourceType;&&&&&&&&[picker release];&&&&&&&&[self presentModalViewController:picker animated:YES];&&&&}else&&&&{&&&&&&&&NSLog(@"模拟其中无法打开照相机,请在真机中使用");&&&&}}&//打开本地相册-(void)LocalPhoto{&&&&UIImagePickerController *picker = [[UIImagePickerController alloc] init];&&&&&picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;&&&&picker.delegate = self;&&&&//设置选择后的图片可被编辑&&&&picker.allowsEditing = YES;&&&&[self presentModalViewController:picker animated:YES];&&&&[picker release];}&//当选择一张图片后进入这里-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info&{&&&&&NSString *type = [info objectForKey:UIImagePickerControllerMediaType];&&&&&//当选择的类型是图片&&&&if ([type isEqualToString:@"public.image"])&&&&{&&&&&&&&//先把图片转成NSData&&&&&&&&UIImage* image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];&&&&&&&&NSData *data;&&&&&&&&if (UIImagePNGRepresentation(image) == nil)&&&&&&&&{&&&&&&&&&&&&data = UIImageJPEGRepresentation(image, 1.0);&&&&&&&&}&&&&&&&&else&&&&&&&&{&&&&&&&&&&&&data = UIImagePNGRepresentation(image);&&&&&&&&}&&&&&&&&&//图片保存的路径&&&&&&&&//这里将图片放在沙盒的documents文件夹中&&&&&&&&NSString * DocumentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];&&&&&&&&&&&//文件管理器&&&&&&&&NSFileManager *fileManager = [NSFileManager defaultManager];&&&&&&&&&//把刚刚图片转换的data对象拷贝至沙盒中 并保存为image.png&&&&&&&&[fileManager createDirectoryAtPath:DocumentsPath withIntermediateDirectories:YES attributes:nil error:nil];&&&&&&&&[fileManager createFileAtPath:[DocumentsPath stringByAppendingString:@"/image.png"] contents:data attributes:nil];&&&&&&&&&//得到选择后沙盒中图片的完整路径&&&&&&&&filePath = [[NSString alloc]initWithFormat:@"%@%@",DocumentsPath,&&@"/image.png"];&&&&&&&&&//关闭相册界面&&&&&&&&[picker dismissModalViewControllerAnimated:YES];&&&&&&&&&//创建一个选择后图片的小图标放在下方&&&&&&&&//类似微薄选择图后的效果&&&&&&&&UIImageView *smallimage = [[[UIImageView alloc] initWithFrame:&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& CGRectMake(50, 120, 40, 40)] autorelease];&&&&&&&&&&&&&smallimage.image = image;&&&&&&&&//加在视图中&&&&&&&&[self.view addSubview:smallimage];&&&&&} &}&- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{&&&&NSLog(@"您取消了选择图片");&&&&[picker dismissModalViewControllerAnimated:YES];}&-(void)sendInfo{&&&&NSLog(@"图片的路径是:%@", filePath);&&&&&NSLog(@"您输入框中的内容是:%@", _textEditor.text);}&- (void)viewDidUnload{&&&&[super viewDidUnload];&&&&// Release any retained subviews of the main view.}&- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{&&&&return (interfaceOrientation == UIInterfaceOrientationPortrait);}&@end
如下图所示,打开下拉菜单按钮开始选择打开相机 或者 打开本地相册。模拟器中是无法打开照相机的的,切记。
如下图所示,这里就是我本地的相册啦,里面保存了几张图片,选择一张即可。
我在这里再说说图片上传, 图片上传我们采用的是2进制ASIHTTPRequest 来完成的。
123456789101112131415
&&&&NSString *server_base = [NSString stringWithFormat:@"%@/users/uploadResource.json", _server];&&&&&ASINetworkQueue *queue = [[ASINetworkQueue alloc] init];&&&&&&&ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:server_base]];&&&&&[ASIHTTPRequest setShouldUpdateNetworkActivityIndicator: NO];&&&&[request setDelegate :self];&&&&[request setDidFinishSelector:@selector(sendCommentSucc:)];&&&&[request setDidFailSelector:@selector(sendCommentFail:)];&&&&// res 就是 需要上传图片文件的路径&&&&[request setFile:res forKey:@"res"];&&&&&[queue addOperation:request];&&&&[queue go];
最后是文本的源码,雨松MOMO祝大家学习愉快,不早了,我也得睡觉啦,1点多了。。。
下载地址:
本文固定链接:
转载请注明:
雨松MOMO提醒您:亲,如果您觉得本文不错,快快将这篇文章分享出去吧 。另外请点击网站顶部彩色广告或者捐赠支持本站发展,谢谢!
作者:雨松MOMO
专注移动互联网,Unity3D游戏开发
如果您愿意花10块钱请我喝一杯咖啡的话,请用手机扫描二维码即可通过支付宝直接向我捐款哦。
您可能还会对这些文章感兴趣!
Pingback 引用通告:
Pingback 引用通告:
Pingback 引用通告:
Pingback 引用通告:

我要回帖

更多关于 常用地基处理方法 的文章

 

随机推荐