对图库的操作

选择相册: UIImagePickerControllerSourceTypesourceType=UIImagePickerControllerSourceTypeCamera;
   if (![UIImagePickerControllerisSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
       sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
   }
   UIImagePickerController * picker = [[UIImagePickerControlleralloc]init];
   picker.delegate = self;
   picker.allowsEditing=YES;
   picker.sourceType=sourceType;
   [self presentModalViewController:picker animated:YES];
选择完毕:  -(void)imagePickerController:(UIImagePickerController*)pickerdidFinishPickingMediaWithInfo:(NSDictionary *)info
{
   [picker dismissModalViewControllerAnimated:YES];
   UIImage * image=[info objectForKey:UIImagePickerControllerEditedImage];
   [self performSelector:@selector(selectPic:) withObject:imageafterDelay:0.1];
}
 -(void)selectPic:(UIImage*)image
{
   NSLog(@"image%@",image);
   imageView = [[UIImageView alloc] initWithImage:image];
   imageView.frame = CGRectMake(0, 0, image.size.width, image.size.height);
[self.viewaddSubview:imageView];
   [self performSelectorInBackground:@selector(detect:) withObject:nil];
}
detect 为自己定义的方法,编辑选取照片后要实现的效果 取消选择:  -(void)imagePickerControllerDIdCancel:(UIImagePickerController*)picker  

{
   [picker dismissModalViewControllerAnimated:YES];
}  
时间: 2024-12-30 02:24:49

对图库的操作的相关文章

iOS开发中一些有用的小代码

1.判断邮箱格式是否正确的代码: //利用正则表达式验证 -(BOOL)isValidateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@&qu

常用代码整理(重要)

常用代码整理: 1.判断邮箱格式是否正确的代码: //利用正则表达式验证 -(BOOL)isValidateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATC

oc 开发ios代码片段

1.判断邮箱格式是否正确的代码 //利用正则表达式验证 -(BOOL)isValidateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@&quo

iOS开发常用代码片段整理

1.判断邮箱格式是否正确的代码 //利用正则表达式验证 -(BOOL)isValidateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@&quo

iOS 常用代码块

1.判断邮箱格式是否正确的代码: // 利用正则表达式验证 -( BOOL )isValidateEmail:( NSString  *)email { NSString  *emailRegex =  @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}" ; NSPredicate  *emailTest = [ NSPredicate   predicateWithFormat : @"SEL

iOS开发之17个常用代码整理

1.判断邮箱格式是否正确的代码 //利用正则表达式验证 -(BOOL)isValidateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES%@&quo

17个常用代码整理

本文由会员诸神的黄昏曲分享 1.判断邮箱格式是否正确的代码 //利用正则表达式验证 -(BOOL)isValidateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF

iOS开发中经常用的实用代码合集

iOS开发中经常用的实用代码合集 本文整理了,在iOS开发中我们所遇到一些开发问题的技巧类的代码,让你在开发过程中避免了很多弯路,希望能给你的开发带来帮助和启发. 1.判断邮箱格式是否正确的代码: // 利用正则表达式验证 -( BOOL )isValidateEmail:( NSString  *)email { NSString  *emailRegex =  @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,4}&

iOS 常用到的关键代码

iOS开发中最有用关键的代码合集(1) 本文整理了,在iOS开发中我们所遇到一些开发问题的技巧类的代码,让你在开发过程中避免了很多弯路,希望能给你的开发带来帮助和启发. 1.判断邮箱格式是否正确的代码: // 利用正则表达式验证 -( BOOL )isValidateEmail:( NSString  *)email { NSString  *emailRegex =  @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}" ; NSPr