小编San*_*osh的帖子

向下滚动时,UICollectionView中的图像会自动翻转?

我正在使用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)

iphone ios uicollectionview uicollectionviewcell ios7

10
推荐指数
1
解决办法
1259
查看次数

URLSession不会在标头swift 4中传递"授权"键

我试图在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)

正如您所看到的,我尝试在会话配置和请求中设置令牌,但没有一个正在工作.

ios nsurlsession swift

7
推荐指数
2
解决办法
6001
查看次数

Spring中的CORS请求无效

我正在尝试启用某些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请求无效.谁能帮我这个?

spring cors spring-boot

6
推荐指数
1
解决办法
5268
查看次数

从iOS照片库中删除图像

我创建了一个应用程序,它从手机的照片库中提取图像并将其显示在集合视图中.现在,我希望每当用户选择图像并单击删除按钮时,特定图像将从集合视图以及图像库中删除.我正在使用ALAssetLibrary来获取图像.我搜索了很多,但没有找到任何方法从照片库中删除图像.

任何人都可以告诉我如何从我的应用程序中以编程方式从照片库中删除照片.

objective-c ios alassetslibrary

5
推荐指数
1
解决办法
5262
查看次数

如何在 MKMapView 中显示整个地球仪

我正在开发一个地图应用程序,我希望用户能够缩小到整个地球。我正在使用 MKMapView。我看到iOS地图应用中有这个功能。

谁能告诉我如何在我的应用程序中实现相同的目标。

iPhone 地图应用程序截图

mapkit mkmapview ios swift swift3

2
推荐指数
1
解决办法
3153
查看次数