我一直在寻找,但无法找到答案.我有一个按钮"拍照",当按下时,它打开相机,你拍照,当你选择"使用照片",我希望它保存到照片库.
我可以做除了保存到图书馆以外的所有人,有人可以帮忙吗?
更新:
我尝试将一个字符串值添加到"NSPhotoLibraryUsageDescription"
键.
它的工作原理.我的TestFlight现在提供了构建版本.
但是我想知道为什么Apple Store只让我为"NSPhotoLibraryUsageDescription"
key而不是"Camera Usage Description"
或者添加String值"Location When In Use Usage Description"
?以及如何本地化info.plist.
亲爱的开发者,
我们发现您最近为"家庭健康追踪器"发送的一个或多个问题.要处理您的交付,必须纠正以下问题:
此应用程序尝试在没有使用说明的情况下访问隐私敏感数据.应用程序的Info.plist必须包含一个NSPhotoLibraryUsageDescription键,其中包含一个字符串值,向用户解释应用程序如何使用此数据.
一旦纠正了这些问题,您就可以重新更新已更正的二进制文件.
问候,
App Store团队
他们仍然告诉我添加NSPhotoLibraryUsageDescription
自升级到XCode8 GM和ios10以来,通过Interface Builder创建的所有视图都没有正确初始化,直到比预期要晚得多.这意味着在viewDidLoad,cellForRowAtIndexPath,viewWillAppear等中,每个视图的帧大小都设置为{1000,1000}.在某些时候他们似乎是正确的,但它为时已晚.
遇到的第一个问题是全面的角落圆角失败:
view.layer.cornerRadius = view.frame.size.width/2
Run Code Online (Sandbox Code Playgroud)
对于依赖于帧大小在代码中进行计算的任何事情,都会出现进一步的问题.
cellForRowAtIndexPath
Run Code Online (Sandbox Code Playgroud)
对于cellForRowAtIndexPath,帧大小在初始表显示时失败,但滚动后它可以正常工作.willDisplayCell:forRowAtIndexPath也没有正确的帧大小.
我已经对一些值进行了硬编码,但显然这是非常糟糕的代码实践,在我的项目中也是如此.
有没有办法或地方获得正确的框架尺寸?
编辑
我发现使用高度/宽度约束而不是帧宽高度更可靠.这可能会增加需要大量新IBOutlet的开销,以链接项目的高度/宽度约束.
现在我已经创建了一个UIView类,它允许我在没有IBOutlets的情况下直接访问View的高度/宽度约束.对于最小的使用,小循环不应该是一个大问题.对于没有明显创建宽度/高度约束的IB项目,不能保证结果.可能最好为常数返回0,或者更糟.此外,如果您没有高度/宽度约束,并且您的视图基于前导/尾随约束动态调整大小,则这将不起作用.
-viewDidLoad似乎具有正确的帧大小,但如果您在此处进行修改,通常会导致UI的可视更改.
UIView的+ WidthHeightConstraints.h
@interface UIView (WidthHeightConstraints)
-(NSLayoutConstraint*)widthConstraint;
-(NSLayoutConstraint*)heightConstraint;
-(NSLayoutConstraint*)constraintForAttribute:(NSLayoutAttribute)attribute;
@end
Run Code Online (Sandbox Code Playgroud)
UIView的+ WidthHeightConstraints.m
#import "UIView+WidthHeightConstraints.h"
@implementation UIView (WidthHeightConstraints)
-(NSLayoutConstraint*)widthConstraint{
return [self constraintForAttribute:NSLayoutAttributeWidth];
}
-(NSLayoutConstraint*)heightConstraint {
return [self constraintForAttribute:NSLayoutAttributeHeight];
}
-(NSLayoutConstraint*)constraintForAttribute:(NSLayoutAttribute)attribute {
NSLayoutConstraint *targetConstraint = nil;
for (NSLayoutConstraint *constraint in self.constraints) {
if (constraint.firstAttribute == attribute) {
targetConstraint = constraint;
break;
}
}
return targetConstraint;
}
@end
Run Code Online (Sandbox Code Playgroud)
编辑2
事实证明,上述类别只是部分有效.主要是因为ios似乎自动添加一些额外的高度/宽度约束重复项,类型为NSContentSizeLayoutConstraint,实际上与普通约束的大小不同.NSContentSizeLayoutConstraint也是一个私有类,所以我不能做isKindOfClass来过滤掉那些.我还没有找到另一种有效测试的方法.这很烦人.
使用iOS 10的Apple已弃用openURL:for openURL:option:completionHandler如果我有:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.google.com"]];
Run Code Online (Sandbox Code Playgroud)
它将如何变成?选项:<#(nonnull NSDictionary*)#>详细说明
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.google.com"] options:<#(nonnull NSDictionary<NSString *,id> *)#> completionHandler:nil];
Run Code Online (Sandbox Code Playgroud)
谢谢
更新选项:@ {}对于没有键和值的空字典 http://useyourloaf.com/blog/querying-url-schemes-with-canopenurl/
我在Xcode控制台视图上收到以下消息
libMobileGestalt MobileGestaltSupport.m:153:pid 231(myproject)没有为frZQaeyWLUvLjeuEK43hmg提供沙箱访问权限且未正确授权
libMobileGestalt MobileGestalt.c:550:无法访问InverseDeviceID(请参阅参考资料)
MacOs Sierra版本:10.12.4 Xcode版本8.3编程语言:目标C.
我在应用程序启动后收到此消息,在运行应用程序时使用xcode插入设备.这似乎是一个罕见的问题.有人可以帮我解决这个问题吗?
我有一些代码返回新的iOS 10/Swift 3 NSData替换(?)类型:数据
if let jpegData = UIImageJPEGRepresentation(newImage, 0.8) { ... }
Run Code Online (Sandbox Code Playgroud)
我想将此映像写入磁盘,但writeToFile:
此类不存在NSData的方法.它确实有一个writeToURL:
方法,但似乎不适用于文件路径(和附加组件).
任何人都可以澄清我现在将如何做到这一点,就像Swift 2中的情况一样:
jpegData.writeToFile(imagePath, atomically: true)
Run Code Online (Sandbox Code Playgroud)
谢谢!
我用iOS 10 Beta 7和Xcode 8 beta测试了我的应用程序,一切正常.然而就在几分钟前,我安装了现在可用的两种GM版本,并遇到了一个奇怪的问题.
我在我的应用程序和我正在使用的自定义单元格中使用自定义表格视图单元格cornerRadius
并clipsToBounds
创建圆形视图.
- (void)awakeFromNib {
[super awakeFromNib];
self.tag2label.layer.cornerRadius=self.tag2label.frame.size.height/2;
self.tag2label.clipsToBounds=YES;
}
Run Code Online (Sandbox Code Playgroud)
这看起来还不错,然而在新的GM版本中,所有圆角的视图都消失了.这发生了UIView
,UILabels
和UIButtons
.
我在下面解决了这个
我在iOS10中安排新通知,如下所示:
func scheduleNotification (event : Meeting, todaysBadgeCounter: Int) {
if #available(iOS 10.0, *) {
let minutesBefore = 10
//interval in seconds from current point in time to notification
let interval : NSTimeInterval = NSTimeInterval(secondsFromNowTo(event.startTime.dateByAddingTimeInterval(-minutesBefore * 60)))
//only schedule in the future
if(interval > 0){
let category = NotificationsController.notificationCategory
let center = NotificationsController.notificationCenter
center.setNotificationCategories([category])
let content = UNMutableNotificationContent()
content.title = NSString.localizedUserNotificationStringForKey(event.title, arguments: nil)
if(minutesBefore <= 1){
content.body = NSString.localizedUserNotificationStringForKey("IOS10: Your \(event.title) is about to start", arguments: nil)
}else{
content.body = NSString.localizedUserNotificationStringForKey("IOS10: …
Run Code Online (Sandbox Code Playgroud) Xcode日志显示在Xcode 8.1,ios 10.1中运行时出现上述错误.有什么问题或者我应该忽略并继续吗?
ios10 ×10
objective-c ×5
ios ×4
xcode8 ×4
iphone ×2
swift3 ×2
xcode ×2
xcode8.1 ×2
autolayout ×1
frame ×1
nsdata ×1
nsurl ×1
swift ×1
testflight ×1