嘿,我是 iPhone 新手,我一直在尝试制作一个画廊类的应用程序。基本上,我想要做的是,我需要将所有捕获的图像保存到特定文件夹中,例如与 iPhone 设备库中我们的应用程序名称相关的新相册“My_App Images”,它对我有用,但我无法更改图像文件名,我不知道是否可以指定文件名?使用 iPhoto,目前我得到的图像文件名为“IMG_0094.jpg”,我们可以通过编程方式将其更改为任何其他文件名(例如“Anyfilename.png”格式)吗?
这是我将图像保存到特定相册的代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[self.library saveImage:image toAlbum:@"My_App Images" withCompletionBlock:^(NSError *error) {
if (error!=nil) {
NSLog(@"Image saving error: %@", [error description]);
}
}];
[picker dismissViewControllerAnimated:NO completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
任何可供参考的来源或链接都值得赞赏。谢谢您的帮助!
嘿,我刚接触iPhone,最近一直在尝试制作一个应用。基本上,我想做的是,如果用户将从相机捕获任何图像,则应将其保存在设备库中。我知道如何将照片保存在图库中,这对我来说是有效的,但是我无法将所有捕获的图像保存到设备图库中的特定文件夹(例如新相册)中。我希望用户能够拍摄多张图片,然后将图片从该特定文件夹复制到图库。
这是我的代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info valueForKey:UIImagePickerControllerMediaType];
if([mediaType isEqualToString:(NSString*)kUTTypeImage]) {
UIImage *photoTaken = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
self.imageView.image = photoTaken;
//Save Photo to library only if it wasnt already saved i.e. its just been taken
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(photoTaken, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
}
[picker dismissViewControllerAnimated:YES completion:NULL];
}
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
UIAlertView *alert;
if (error) {
alert = [[UIAlertView alloc] initWithTitle:@"Error!"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
} …
Run Code Online (Sandbox Code Playgroud) 我上传了我的一个应用程序Apple Store
,它的实时.现在我需要发送metadata
相同应用程序的新版本.但在为第二个版本上传新二进制文件之前,我需要更改large app icon (1024x1024)
.目前,我的新版本应用状态为"准备上传",iTunes连接上的第一个版本应用状态为"Ready for sale".现在点击版本信息部分中的编辑选项.我已经成功更改了应用程序大徽标..但是当我点击保存按钮时,它没有正确保存,我收到以下错误:
Select a frequency/intensity level for each Apple content description.
Run Code Online (Sandbox Code Playgroud)
我也检查了这个链接:如何在iTunes连接上更改应用商店的大图标?
我认为此错误与评级相关,我已将Apple内容描述的所有评级均为无(总共4+评级).请帮我解决这个错误.我附上截图供参考..谢谢
我正在 Swift3 iOS 中开发视频应用程序。基本上我必须将视频资产和音频与淡入淡出效果合并为一个并将其保存到 iPhone 画廊。为此,我使用以下方法:
private func doMerge(arrayVideos:[AVAsset], arrayAudios:[AVAsset], animation:Bool, completion:@escaping Completion) -> Void {
var insertTime = kCMTimeZero
var audioInsertTime = kCMTimeZero
var arrayLayerInstructions:[AVMutableVideoCompositionLayerInstruction] = []
var outputSize = CGSize.init(width: 0, height: 0)
// Determine video output size
for videoAsset in arrayVideos {
let videoTrack = videoAsset.tracks(withMediaType: AVMediaTypeVideo)[0]
let assetInfo = orientationFromTransform(transform: videoTrack.preferredTransform)
var videoSize = videoTrack.naturalSize
if assetInfo.isPortrait == true {
videoSize.width = videoTrack.naturalSize.height
videoSize.height = videoTrack.naturalSize.width
}
outputSize = videoSize
}
// Init composition
let mixComposition …
Run Code Online (Sandbox Code Playgroud) 我正在尝试UIImage
从中的自定义文本生成一个Swift3
。
使用iOS Controls
,可以创建一个UIImage,下面是代码:
class func imageWithText(txtField: UITextField) -> UIImage {
UIGraphicsBeginImageContextWithOptions(txtField.bounds.size, false, 0.0)
txtField.layer.render(in: UIGraphicsGetCurrentContext()!)
let img = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return img!
}
Run Code Online (Sandbox Code Playgroud)
注意:我知道也可以在图像中添加一些文本,但是我不想这样做。
有人可以帮我解决这个问题吗?谢谢!
我刚接触iPhone.我在我的应用程序中添加了一个使用XIB的UITextView,现在点击完成键后,它只是简单地重新键盘.但是,我想通过点击它创建一个新行,意味着它应该转到下一段.请帮我实现我的输出.这是我的代码:
- (void)textViewDidEndEditing:(UITextView *)textView1
{
if (![textView1 hasText]) {
[textView1 addSubview:placeholderLabel];
}
else{
NSLog(@"done button clicked!!");
}
CGRect rect;
if(screenBounds.size.height == 568)//iPhone5
{
rect = CGRectMake(5, 76, 310, 491);
}
else{
if(_kisiOS7){
rect = CGRectMake(5, 76, 310, 404);
}
else{
rect = CGRectMake(0, 44, 320, 436);
}
}
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
txtView.frame = rect;
[UIView commitAnimations];
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if (range.length == 0) {
if ([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
return NO;
} …
Run Code Online (Sandbox Code Playgroud) 我正在创建一个Video
应用程序Swift3
。Video
我们在列表中有一个文件列表TableView
。对于每个,我们都为用户Video
提供了选择的选项。现在我正在尝试播放用户选择的特定范围。Range Slider
Range
Video
Video
我正在使用下面的代码来启动Video
4 秒到 8 秒的使用CMTimeMake
,但无法正确播放。
let targetTime:CMTime = CMTimeMake(4, 1)////Video start
self.player?.seek(to: targetTime)
self.player?.currentItem?.forwardPlaybackEndTime = CMTimeMake(8, 1)//Video stop
self.player?.play()
Run Code Online (Sandbox Code Playgroud)
谁能帮助我哪里做错了。谢谢。