我正在使用UICollectionView,我正在显示手机照片库中的所有图像.
当我点击任何图像时,图像会被翻转,并显示有关图像的一些信息.
当用户再次点击同一图像时,图像再次翻转并显示原始图像.
问题是每当我向下滚动UICollectionView时,最后选择的图像会自动翻转,并显示有关图像的信息.
如何阻止这个问题.
这是一些代码:
- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell1 = [collectionView cellForItemAtIndexPath:indexPath];
if(old_path!=NULL){
UICollectionViewCell *cell2 = [collectionView cellForItemAtIndexPath:old_path];
[UIView transitionFromView:cell2.selectedBackgroundView toView:cell2.contentView duration:0.5 options:UIViewAnimationOptionCurveLinear |UIViewAnimationOptionTransitionFlipFromLeft completion:nil];
}
if(old_path==indexPath&&flag)
{
[cell1 setSelected:NO];
[UIView transitionFromView:cell1.selectedBackgroundView toView:cell1.contentView duration:0.5 options:UIViewAnimationOptionCurveLinear |UIViewAnimationOptionTransitionFlipFromLeft completion:nil];
flag=FALSE;
}
else{
[UIView transitionFromView:cell1.contentView toView:cell1.selectedBackgroundView duration:0.5 options:UIViewAnimationOptionCurveLinear |UIViewAnimationOptionTransitionFlipFromLeft completion:nil];
flag=TRUE;
}
old_path=indexPath;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
ALAsset *asset = assets[indexPath.row];
NSLog(@"Description : %@",[asset description]);
UIImage *img=[self imageWithImage:[UIImage imageWithCGImage:[asset …Run Code Online (Sandbox Code Playgroud) 我试图在URLRequest的标头中传递授权密钥.但是在服务器端没有收到密钥.从邮递员工作正常时调用相同的API.标头中的任何其他键工作正常,甚至授权密钥在服务器端也可见.
这是我的代码:
let headers = [
"authorization": "token abcd"
]
var request = URLRequest.init(url: NSURL(string:
"http://127.0.0.1:7000/api/channels?filter=contributed")! as URL)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let config = URLSessionConfiguration.default
config.httpAdditionalHeaders = headers
let session = URLSession.init(configuration: config)
let dataTask = session.dataTask(with: request, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error ?? "")
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse ?? "")
}
})
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我尝试在会话配置和请求中设置令牌,但没有一个正在工作.
我正在尝试启用某些IP来访问特定方法.
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/updateDetail")
.allowedOrigins("127.0.0.1", "10.96.33.45")
.allowedMethods("GET", "POST");
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试调用相同的方法时,我收到的CORS请求无效.谁能帮我这个?
我创建了一个应用程序,它从手机的照片库中提取图像并将其显示在集合视图中.现在,我希望每当用户选择图像并单击删除按钮时,特定图像将从集合视图以及图像库中删除.我正在使用ALAssetLibrary来获取图像.我搜索了很多,但没有找到任何方法从照片库中删除图像.
任何人都可以告诉我如何从我的应用程序中以编程方式从照片库中删除照片.
ios ×4
swift ×2
cors ×1
ios7 ×1
iphone ×1
mapkit ×1
mkmapview ×1
nsurlsession ×1
objective-c ×1
spring ×1
spring-boot ×1
swift3 ×1