首先,我从照片库中选择了图像到ALAsset库,之后我将图像存储在ALAsset库路径的文档目录中.
我正在使用此代码将图像存储在ALAsset Library的文档目录中....它的工作完美...现在我想在表视图中显示存储在文档目录中的所有图像..我该怎么做?有谁能够帮我??
用于将图像从ALAsset Library导入NSdocument目录的代码
for (int j=0; j<[assetArray count]; j++) {
ALAssetRepresentation *representation = [[assetArray objectAtIndex:j] defaultRepresentation];
NSString* filename = [documentPath stringByAppendingPathComponent:[representation filename]];
[[NSFileManager defaultManager] createFileAtPath:filename contents:nil attributes:nil];
NSOutputStream *outPutStream = [NSOutputStream outputStreamToFileAtPath:filename append:YES];
[outPutStream open];
long long offset = 0;
long long bytesRead = 0;
NSError *error;
uint8_t * buffer = malloc(131072);
while (offset<[representation size] && [outPutStream hasSpaceAvailable]) {
bytesRead = [representation getBytes:buffer fromOffset:offset length:131072 error:&error];
[outPutStream write:buffer maxLength:bytesRead];
offset = offset+bytesRead;
}
[outPutStream close];
free(buffer);
Run Code Online (Sandbox Code Playgroud)
}
之后,我使用此代码获取目录的内容: …
我想在ios中更改我的谷歌地图样式.为此,我试图实现此代码. GMSMapStyle
我正在进口import GoogleMaps
.但是我收到了这个错误Use of unresolved identifier GMSMapStyle
.任何人都可以帮助我导入哪个模块以避免此错误.提前致谢
我想检测UIDeviceOrientationFaceDown.我怎样才能做到这一点???实际上我想在我的iphone面朝下平面时执行一些操作.这怎么可能???请帮助我这样做.
我有这个代码,但不知道在何处以及如何应用此代码
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
BOOL getOrientationUpdates = [[UIDevice currentDevice] isGeneratingDeviceOrientationNotifications];
NSLog(@"will receive orientation notifications: %@", getOrientationUpdates?@"YES":@"NO");
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
Run Code Online (Sandbox Code Playgroud)
如果有任何教程,请建议我
在此先感谢,非常欢迎您的宝贵帮助和建议.
我已经在swift 3中转换了我的代码.我在我的应用程序中使用核心数据.如您所知,NSFetchRequest已更改.在swift 2中它是:
let request = NSFetchRequest(entityName: "UnsyncedTask")
Run Code Online (Sandbox Code Playgroud)
在快速3:
let request:NSFetchRequest<NSFetchRequestResult> = UnsyncedTask.fetchRequest()
Run Code Online (Sandbox Code Playgroud)
我的问题是,它只支持ios 10.如何才能使ios兼容?我想要支持ios 9的NSFetchRequest,带有swift 3的ios 10.
我想在一个显示图像TableView
.我可以在一个单元格中显示一个图像,但是我希望在每一行中显示四个图像而不是一个图像,如照片库,当我选择任何图像时,它将像照片库中的幻灯片一样打开.
我的图像存储在文档目录中.我怎样才能做到这一点?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tablView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
//Adjust your imageview frame according to you
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0, 0.0, 470.0, 80.0)];
[imageView setImage:[arrayOfImages objectAtIndex:indexPath.row]];
[cell.contentView addSubview:imageView];
return cell;
}
Run Code Online (Sandbox Code Playgroud) 我如何检查NSURL是否有效?1)如果我输入"facebook.com",那么它应该添加" http:// www."
2)如果我输入"www.facebook.com",则应添加"http://"
3)如果我输入"facebook",那么它应该在google上搜索.
我怎么能做到这一点?
我正在按照以下方式进行此操作,但它无法正常工作.第三种情况总是如此.(" http://www.facebook ")
if (![url.absoluteString.lowercaseString hasPrefix:@"http://"])
{
if(![url.absoluteString.lowercaseString hasPrefix:@"www."])
{
url = [NSURL URLWithString:[@"http://www." stringByAppendingString:locationField.text]];
}
else
{
url = [NSURL URLWithString:[@"http://" stringByAppendingString:locationField.text]];
}
}
if(![self validateUrl:url.absoluteString])
{
url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.google.com/search?q=%@",[locationField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
}
- (BOOL) validateUrl:(NSString *)candidate
{
NSString *urlRegEx = @"((https|http)://)((\\w|-)+)(([.]|[/])((\\w|-)+))+";
NSPredicate *urlTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", urlRegEx];
return [urlTest evaluateWithObject:candidate];
}
Run Code Online (Sandbox Code Playgroud) iphone ×4
objective-c ×4
ios ×3
ios5 ×3
core-data ×1
google-maps ×1
ios10 ×1
nspredicate ×1
nsurl ×1
search ×1
swift ×1
swift3 ×1
uitableview ×1