在开发iOS应用程序时,我需要在具有暗模式选项的模拟器中对其进行测试,以便我可以更清楚地了解应用程序UI。但是,当我转到“设置”时,我无法获得深色模式的选项,如真实设备所示。

我想知道如何用这样的按钮创建一个popover.
回答:
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle: nil
delegate: self
cancelButtonTitle: nil
destructiveButtonTitle: nil
otherButtonTitles: @"Take Photo",
@"Choose Existing Photo", nil];
[actionSheet showFromRect: button.frame inView: button.superview animated: YES];
Run Code Online (Sandbox Code Playgroud)
委托对象类中的其他位置......
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
// take photo...
}
else if (buttonIndex == 1) {
// choose existing photo...
}
}
Run Code Online (Sandbox Code Playgroud) uiactionsheet ipad uipopovercontroller ios uialertcontroller
UIWebView是否使用与Mobile Safari相同的JavaScript引擎?
此外,UIWebView是否支持Mobile Safari等所有HTML5功能?我特别关注Web SQL和Web Workers
如果我有一个完全用HTML和JS编写的应用程序,我应该将它包装在UIWebView中,还是应该在Mobile Safari中打开它
Apple商店是否接受纯HTML和JS应用程序?
我在理解函数类型时遇到问题(它们看起来像是a的Signature模板参数std::function):
typedef int Signature(int); // the signature in question
typedef std::function<int(int)> std_fun_1;
typedef std::function<Signature> std_fun_2;
static_assert(std::is_same<std_fun_1, std_fun_2>::value,
"They are the same, cool.");
int square(int x) { return x*x; }
Signature* pf = square; // pf is a function pointer, easy
Signature f; // but what the hell is this?
f(42); // this compiles but doesn't link
Run Code Online (Sandbox Code Playgroud)
变量f无法分配,但可以调用.奇怪的.那有什么好处呢?
现在,如果我对typedef进行const限定,我仍然可以使用它来构建更多类型,但显然没有别的:
typedef int ConstSig(int) const;
typedef std::function<int(int) const> std_fun_3;
typedef std::function<ConstSig> std_fun_4;
static_assert(std::is_same<std_fun_3, std_fun_4>::value,
"Also the same, …Run Code Online (Sandbox Code Playgroud) 我的应用程序允许用户在UITextField控件中输入数值(货币),但遗憾的是我希望的键盘布局不是内置选项之一,所以我不得不选择"数字和标点符号"选项. Interface Builder.这是IB中相应的对话窗口:
因此,当我的应用程序询问用户输入时,它显示以下内容:
哪个非常好,但请查看用户可用的所有额外密钥!人们可以很容易地输入"12; 56!" 在文本字段中,我假设我必须以某种方式验证.
所以我的问题是:如何验证输入的货币值UITextField?
我有一个iOS应用程序,包含一个包含6个实体的Core Data模型.该实体Name的设置如下:
班级名称:姓名
模块:当前产品模块
可待因:类定义
(所有其他5个实体的设置类似).
问题1(固定自己但留给子孙后代)
代码IS在派生数据文件夹中生成...不是作为预期的〜类定义,而是作为扩展代替(命名为Name+CoreDataProperties.swift.似乎无关紧要,Codegen是否设置为类定义或类别/扩展 - 我仍然得到相同结果.
好吧,坚持这个想法 - 突然间,类和扩展文件现在都在生成......看起来您需要删除项目的派生数据文件夹并在更新之间重新启动Xcode.忽略问题1
问题2
生成的文件忽略数据模型String属性和关系的可选标志设置 - 它们都是作为选项生成的
问题3(固定自己但留给后人)
有序关系生成为OrderedSet(和编译错误)而不是NSOrderedSet(在重新生成时不能更改它们)
我的解决方法是暂时添加到项目中......
public typealias OrderedSet = NSOrderedSet
好的,现在编译器错误已经消失,OrderedSet似乎已被识别.忽略问题3.
问题4
以上都不重要,因为编译器无法找到它刚刚生成的文件.对于上述Name实体:
:0:错误:没有这样的文件或目录:'/ Users/ashleymills/Library/Developer/Xcode/DerivedData/-grfqveelvqtlydbpwjmfdietnrss/Build/Intermediates/.build/Debug-iphonesimulator/.build/DerivedSources/CoreDataGenerated//.Name+ CoreDataClass.swift':0:错误:没有这样的文件或目录:'/ Users/ashleymills/Library/Developer/Xcode/DerivedData/-grfqveelvqtlydbpwjmfdietnrss/Build/Intermediates/.build/Debug-iphonesimulator/.build/DerivedSources/CoreDataGenerated/ /.Name+CoreDataProperties.swift"
它正在寻找文件的派生数据,.Name+CoreDataClass.swift并.Name+CoreDataProperties.swift注意'.' 在文件名的前面.(作为临时修复,我将生成的文件添加到项目中)
我假设我做错了,好像每个人都是这样,没有人能够建立一个核心数据项目......或者这些错误是否需要提升?
干杯灰
(也在Apple dev论坛上提出)
我有一个视图控制器,使用故事板segue在弹出框中显示.
在呈现视图控制器中,我有以下代码:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let svc = segue.destinationViewController as? SettingsViewController {
svc.popoverPresentationController?.delegate = self
}
}
Run Code Online (Sandbox Code Playgroud)
然而,事实证明,所呈现的视图控制器,即使它显示为酥料饼,具有modalPresentationStyle的'.Modal,因此一个nil popoverPresentationController.奇怪的!
所以,我更新了代码如下:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let svc = segue.destinationViewController as? SettingsViewController {
svc.modalPresentationStyle = .Popover
svc.popoverPresentationController?.delegate = self
}
}
Run Code Online (Sandbox Code Playgroud)
该svc.popoverPresentationController代表现在设置好了,但如果酥料饼是由用户解雇攻外,没有任何的UIPopoverPresentationControllerDelegate委托方法(如popoverPresentationControllerShouldDismissPopover被调用.我在想什么?
我们刚刚使用Crittercism框架发布了一个应用程序.一段时间后,我们有大约125K的应用程序负载和95次崩溃 - 率低于0.08%.
一次崩溃发生了19次,另外一起发生了10起,但其他41次发生了3起或更少.如果应用程序出现任何重大问题,我希望在特定领域看到更多失败,所以我对我看到的数字水平感到满意.
快速浏览显示其中许多是低级故障,不是明显造成的,而是程序员错误.
例子
free_list_checksum_botch但我的问题是,在一个足够复杂的操作系统(在这种情况下是iOS)中,有一个足够复杂的应用程序(我认为它是),作为开发人员,我是否应该期望看到这种"背景噪音"?
我应该期望看到每1-2000次加载一个应用程序崩溃,仅仅是因为操作系统不完美?还有其他人有类似的经历吗?
(我不是在寻找错误的解决方案..谢谢!)
我有一个应用程序,我正在尝试接收和处理SILENT推送通知.
我正在注册APN如下:
UNUserNotificationCenter.currentNotificationCenter().delegate = self
UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions([.Badge, .Sound, .Alert]) {(granted, error) in
if granted {
application.registerForRemoteNotifications()
}
}
Run Code Online (Sandbox Code Playgroud)
实现:
func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
// Handle notification
}
func userNotificationCenter(center: UNUserNotificationCenter, willPresentNotification notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) {
// Handle notification
}
Run Code Online (Sandbox Code Playgroud)
该应用程序有UIBackgroundModes fetch和remote-notification
APN内容如下:
{
"aps":{
"content-available":1,
"badge":0
},
"action":"shareDelete",
"shareId":633
}
Run Code Online (Sandbox Code Playgroud)
当应用程序位于前台时,userNotificationCenter(centre:withCompletionHandler:willPresentNotification)会在收到通知时触发,但是当应用程序背景化时,没有任何反应.
我可以通过更改徽章编号看到收到的APN,但在应用程序中没有触发任何内容.
我错过了什么?
(也在Apple开发论坛上询问)
我的下面的代码与swift 4工作得很好但升级到swift 4.2后我收到了这个错误,我浪费了3个小时搜索问题但是失败了.如果有人可以指导我如何解决这个问题.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if postType == 2 {
let image = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey)] as! UIImage
mediaType.image = image
} else {
videoURL = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.mediaURL)] as? URL
do {
let asset = AVURLAsset(url: videoURL!, options: nil)
let imgGenerator = AVAssetImageGenerator(asset: asset)
imgGenerator.appliesPreferredTrackTransform = true
let cgImage = try imgGenerator.copyCGImage(at: CMTime.init(value: 0, timescale: 1), actualTime: nil)
let thumbnail = UIImage(cgImage: cgImage)
self.mediaType.image = thumbnail
} catch {
print("*** Error generating thumbnail: \(error)")
} …Run Code Online (Sandbox Code Playgroud) ios ×6
ios10 ×2
c++ ×1
c++11 ×1
cocoa-touch ×1
core-data ×1
crash ×1
crittercism ×1
ios-darkmode ×1
ios12 ×1
ipad ×1
iphone ×1
std-function ×1
swift ×1
swift3 ×1
uistoryboard ×1
uiwebview ×1