Apple为每个应用程序引入了新的隐私设置,允许用户决定是否允许应用访问用户的联系人,日历,照片和提醒.当应用程序首次尝试访问其中一个资源时,用户将看到UIAlertView,类似于应用程序想要访问位置时的已知机制.
也可以设置目的字符串,让用户知道应用程序想要访问的原因.但是,现在通过Info.plist中的键完成此操作,例如"联系人的隐私 - 联系人使用说明"(NSContactsUsageDescription).
现在我问自己如何本地化这些值?对于位置目的文本,我曾经使用NSLocalizedString(...)设置CLLocationManager实例的目的属性.如何使用Info.plist中的新密钥执行类似的操作?
附录:新的隐私密钥列在以下链接中,但摘要列不会将它们列为可本地化的:https: //developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/ CocoaKeys.html#// apple_ref/DOC/UID/TP40009251-SW14
我想使用UICollectionView在iPhone上的网格中显示图像,每行显示3个图像.对于"死的简单测试"(我认为),我已经为我的项目添加了15个JPG图像,因此它们将在我的包中,我可以通过[UIImage imageNamed:...]加载它们.
我想我已经做了一切正确的事情(设置和注册UICollectionViewCell子类,使用UICollectionViewDataSource协议方法),但是,UICollectionView表现得非常奇怪:
它仅显示以下模式中的一些图像:第一行显示图像1和3,第二行显示空白,下一行显示第一行(图像1和3显示正确),第四行显示空白等等. .
如果我在我的NavBar中按下一个触发[self.collectionView reloadData]的按钮,则随机单元格会出现或消失.让我疯狂的是,这不仅是图像出现与否的问题.有时,图像也在单元格之间交换,即它们出现在indexPath中,它们绝对没有连线!
这是我的单元格代码:
@interface AlbumCoverCell : UICollectionViewCell
@property (nonatomic, retain) IBOutlet UIImageView *imageView;
@end
@implementation AlbumCoverCell
@synthesize imageView = _imageView;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
_imageView = [[UIImageView alloc] initWithFrame:frame];
[self.contentView addSubview:_imageView];
}
return self;
}
- (void)dealloc
{
[_imageView release];
[super dealloc];
}
- (void)prepareForReuse
{
[super prepareForReuse];
self.imageView.image = nil;
}
@end
Run Code Online (Sandbox Code Playgroud)
我的UICollectionViewController子类的部分代码,其中'imageNames'是一个包含所有jpg文件名的NSArray:
- (void)viewDidLoad
{
[super viewDidLoad];
[self.collectionView registerClass:[AlbumCoverCell class] forCellWithReuseIdentifier:kAlbumCellID];
}
#pragma mark - UICollectionViewDataSource Protocol …Run Code Online (Sandbox Code Playgroud) 在Xcode 3中调试程序时,我经常在单独的窗口中使用Memory Browser来查看缓冲区更改的内容,同时我逐步执行代码行.
我现在开始使用Xcode 4,我想知道如何打开内存浏览器.我在UI中找不到类似的东西.有人可以提供帮助吗?
我想在另一个Info.plist键(NSContactsUsageDescription)的值内使用'Bundle display name'(CFBundleDisplayName)的值.
我尝试了以下,但这不起作用:
${CFBundleDisplayName} must access your Address Book to input the scanned contact
information. ${CFBundleDisplayName} will never access your Address Book for marketing
or advertising purposes.
Run Code Online (Sandbox Code Playgroud)
有谁知道怎么做?
附录:解决方案在本地化价值时也应该有效.
我已经编写了一个静态框架,其中我有一个名为ViewfinderViewController的类,它使用AVCaptureSession设置摄像机.此ViewController还将AVCaptureVideoPreviewLayer添加为其自己视图层的子图层:
// code in ViewfinderViewController.m
previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:captureSession];
previewLayer.frame = self.view.bounds;
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.view.layer addSublayer:previewLayer];
Run Code Online (Sandbox Code Playgroud)
ViewfinderViewController还进行一些视频处理,并提供框架的用户注册一些委托方法,以防发现感兴趣或在其中一个处理过的帧中找不到.
在我的实际应用程序的viewDidLoad方法中,我创建了一个ViewfinderViewController实例,设置它的框架并将其视图添加为子视图:
// code in the app's view controller viewDidLoad method
ViewfinderViewController *vfVC = [[ViewfinderViewController alloc] init];
vfVC.view.frame = self.view.bounds;
[self.view addSubview:vfVC.view];
Run Code Online (Sandbox Code Playgroud)
只要我无视旋转(我直到现在这样做),这样做很好.我的主要问题是,ViewfinderViewController.view调整了框架的大小,但AVCaptureVideoPreviewLayer却没有.我有点困惑:请不要自动调整previewLayer的大小,因为对应于它的superLayer的视图是否正确调整大小?
有任何想法吗?我很乐意提供更多信息,但为了缩短问题,我现在不再进一步了解.谢谢.