在我的应用程序中,有一个选择照片按钮,当点击按钮时,它应该拍摄 iPhone 照片并只显示图像而不显示视频。使用我的代码,它显示图像和视频。只显示图像的方法是什么.寻求帮助,感谢advanace。下面是我的代码:
#import <AssetsLibrary/AssetsLibrary.h>
-(void)choosePhotoFromExistingImages
{
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])
{
controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
controller.allowsEditing = NO;
controller.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypePhotoLibrary];
controller.delegate = self;
[self.navigationController presentViewController: controller animated: YES completion: nil];
}
Run Code Online (Sandbox Code Playgroud)
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if (picker==controller){
[self.navigationController dismissViewControllerAnimated: YES completion: nil];
UIImage *image1 = [info valueForKey: UIImagePickerControllerOriginalImage];
CGFloat compression = 0.9f;
CGFloat maxCompression = 0.1f;
int maxFileSize = 250*1024;
NSData *imageData = UIImageJPEGRepresentation(image1, compression);
while ([imageData length] > maxFileSize …
Run Code Online (Sandbox Code Playgroud) 我想UITableView
在点击时显示UITextView
.键盘不应该显示.问题在于点击UITextView
两者UITableView
和键盘都显示出来.我只希望显示表格视图.我想显示从Web服务获取的数据,UITextView
这是不可编辑的.按下导航栏中的编辑按钮,点击时UITextView
,UITableView
应该弹出而不是键盘.
我的代码如下:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
return NO;
}
return YES;
}
-(void)textViewDidBeginEditing:(UITextView *)textView{
[self.view endEditing:YES];
tableVw=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 500)];
tableVw.dataSource=self;
tableVw.delegate=self;
[self.view addSubview:tableVw];
}
-(void)viewDidLoad{
[super viewDidLoad];
txtVwDescription=[[UITextView alloc]initWithFrame:CGRectMake(10, 270, 300,stringSize.height+10)];
txtVwDescription.backgroundColor=[UIColor clearColor];
txtVwDescription.layer.cornerRadius=5;
txtVwDescription.backgroundColor=[UIColor colorWithRed:0.662745 green:0.662745 blue:0.662745 alpha:0.3];
[txtVwDescription setFont:[UIFont systemFontOfSize:13.0]];
txtVwDescription.contentInset=UIEdgeInsetsMake(0, 0, 0, 0);
[txtVwDescription setUserInteractionEnabled:NO];
txtVwDescription.editable=NO;
txtVwDescription.delegate=self;
[self.view addSubview:txtVwDescription];
}
-(void)edit{
[txtVwDescription setUserInteractionEnabled:YES];
txtVwDescription.editable=NO; …
Run Code Online (Sandbox Code Playgroud)