小编Out*_*end的帖子

[UICollectionView setCollectionViewLayout:]上的EXC_BAD_ACCESS

我有一个集合视图,我在使用自定义UICollectionViewFlowLayout.此集合视图可以在本地或通过Internet加载图像.如果我在本地加载图像,每个导航都很有效.然而,如果我通过互联网加载图像,屏幕第一次正确加载,但如果你点击图像并转到另一个屏幕,然后从该屏幕返回(它们都在导航控制器中),有一个'糟糕的访问'崩溃.有谁知道可能是什么原因.

在viewDidLoad中

[self.photosCollectionView registerNib:[UINib nibWithNibName:@"PhotoAlbumPhotosCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:kReuseIdentifierPhotosAlbumPhotosCollectionViewCell];
Run Code Online (Sandbox Code Playgroud)

在viewWillAppear中

[self fetchImagesFromInternetAsynchronously]; 

self.photosCollectionView.dataSource = self;
self.photosCollectionView.delegate = self;

self.photosCollectionViewFlowLayout = [UICollectionViewFlowLayout new];
self.photosCollectionViewFlowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
self.photosCollectionViewFlowLayout.minimumInteritemSpacing = 2.0f;
self.photosCollectionViewFlowLayout.minimumLineSpacing = 2.0f;

CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;
CGFloat cellDimension = (screenWidth - 2*self.photosCollectionViewTrailingSpaceConstraint.constant - 3*self.photosCollectionViewFlowLayout.minimumInteritemSpacing)/4 - 1.0;
CGSize cellSize = CGSizeMake(cellDimension, cellDimension);
[self.photosCollectionViewFlowLayout setItemSize:cellSize];

[self.photosCollectionView setCollectionViewLayout:self.photosCollectionViewFlowLayout];
Run Code Online (Sandbox Code Playgroud)

fetchImagesFromInternetAsynchronously,我做了[self.photosCollectionView reloadData]一次图像已被提取.

这是堆栈跟踪:

stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
frame #0: 0x0000000112da0e09 UIKit`-[UICollectionViewData layoutAttributesForItemAtIndexPath:] + 248
frame #1: 0x0000000112d4f2d3 UIKit`-[UICollectionView …
Run Code Online (Sandbox Code Playgroud)

objective-c ios uicollectionview uicollectionviewlayout

7
推荐指数
1
解决办法
3199
查看次数

结构中的Lazy var

任何人都知道如何解决这个问题.在该行,dateFormatter.string(from: date)编译器说"不能在不可变值上使用变异的getter".

struct viewModel {

private lazy var dateFormatter = { () -> DateFormatter in
    let formatter = DateFormatter()
    formatter.dateFormat = "MM/dd/yyyy"
    return formatter
}()

var labelText: String? {
    let date = Date()
    return dateFormatter.string(from: date)
}}
Run Code Online (Sandbox Code Playgroud)

我理解这个链接写的是什么,但上面的情况可能有所不同.

swift

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

通过php脚本发送iOS通知:'无法设置私钥文件'

我使用了众所周知的Ray Wanderlich 教程的php脚本在开发阶段发送推送通知.在我创建pem文件(来自p12和aps_development.cer文件)并在php脚本中提到设备令牌后,它们被正确触发.

但是,当我使用具有生产p12和aps_production.cer文件的pem文件时,通知甚至没有到达APNS服务器.它在本地服务器端本身显示以下错误.

Unable to set private key file `/Users/administrator/Desktop/SimplePush/ck.pem' in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22

Warning: stream_socket_client(): failed to create an SSL handle in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22

Warning: stream_socket_client(): Failed to enable crypto in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22

Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22
Run Code Online (Sandbox Code Playgroud)

可能是什么原因.p12文件没有任何密码(虽然我已经为pem文件配置了密码),这就是它在php脚本中给出的方式.

// Put your private key's passphrase here:
$passphrase = '';
Run Code Online (Sandbox Code Playgroud)

php apple-push-notifications ios

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

使用CABasicAnimation围绕其中心旋转CAShapeLayer弧

我有一个使用CAShapeLayer绘制的圆弧,并且希望它绕圆心旋转。我正在尝试在'transform.rotation'属性上使用CABasicAnimation获得此动画。但是旋转似乎发生在与圆心不同的点上。

-(void)drawRect:(CGRect)rect{
 int radius = 100;
 CAShapeLayer *circle = [CAShapeLayer layer];
 circle.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath;
 circle.fillColor = [UIColor orangeColor].CGColor;
 circle.strokeColor = [UIColor blueColor].CGColor;
 circle.lineWidth = 5;
 circle.strokeStart = 0.0f;
 circle.strokeEnd = 0.1f;
 [self.layer addSublayer:circle];

 CABasicAnimation *spinAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
 spinAnimation.byValue = [NSNumber numberWithFloat:2.0f*M_PI];
 spinAnimation.duration = 4;
 spinAnimation.repeatCount = INFINITY;
 [circle addAnimation:spinAnimation forKey:@"indeterminateAnimation"];
} 
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我知道这是一个老问题,但是出路是什么。通过设置图层的边界或锚点,我进行了很多修改,但它尚未绕中心旋转。

circle.bounds = self.frame;
Run Code Online (Sandbox Code Playgroud)

这是将视图添加到视图控制器的方法。

[self.view addSubview:[[ProgressIndicator alloc] initWithFrame:CGRectMake(50, 50, 200, 200)]];
Run Code Online (Sandbox Code Playgroud)

core-animation calayer

4
推荐指数
1
解决办法
2910
查看次数

WatchKit - 检测力触摸和绕过上下文菜单

当用户执行强制触摸时,是否可以不显示上下文菜单.而是以模态方式显示自定义接口控制器.

或者甚至可以以编程方式检测力触摸.

watchkit

4
推荐指数
1
解决办法
1251
查看次数

在Xcode 4.3.2中将文件拖动到项目时,"编译源"未更新

我只是不确定这是否是Xcode 4.3.2中的错误,或者它应该是这样的.

当我在一段时间后升级到Xcode 4.3.2并将一些文件拖到新创建的项目上时,它在编译时反复抛出链接器错误.所有必需的框架已经链接在一起.事实证明,当我去手动添加我手动拖动到项目中的.m文件时,这些错误消失了,在Build Settings - Compile Sources中.

我在以前版本的Xcode中做了同样的事情,从来没有必须自己更新手动更新编译源.我假设如果将任何.m文件拖入项目,则应自动更新编译源.

我没有任何以前版本的Xcode,我可以在那里测试它,但是想知道这是否真的是Xcode 4.3.2中的一个错误,或者是否还有其他我缺少的东西.

xcode

3
推荐指数
1
解决办法
2534
查看次数

如何在Xcode调试器中打印NSString的地址

通常在lldb调试器中,如果对对象执行po操作,则其地址也会与描述一起显示.但是,如果是NSString,则不显示地址.所以问题是有没有办法看到它.

PS - 源代码中的NSLog%p不是我要找的答案.

xcode pointers nsstring lldb

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