苹果蓝与我的app颜色不匹配,因此打印对话框非常刺耳.
在我的iPhone应用程序中,我可以使用以下UIPrintInteractionControllerDelegate代码获得正确的导航栏和背景颜色.
- (UIViewController *)printInteractionControllerParentViewController: (UIPrintInteractionController *)printInteractionController
{
return self.navigationController;
}
- (void)printInteractionControllerDidPresentPrinterOptions:(UIPrintInteractionController *)printInteractionController
{
self.navigationController.topViewController.view.backgroundColor = [UIColor whiteColor];
}
Run Code Online (Sandbox Code Playgroud)
问题是我使用自定义UIPrintPageRenderer类来呈现我的页面.这似乎触发了在发送打印作业后弹出的屏幕.它有一个导航栏,带有完成按钮,下面有一条消息说"发送到打印机".我认为这是因为你可以看到多个页面被发送(我只有一个).在选项对话框消失后弹出,并且您已返回到原始屏幕,您启动了所有内容.
"发送到打印机"屏幕是蓝色的,最大的丑陋.无论如何要消除它或定制它的外观?"
我在ios 8 beta 4中创建了一个测试项目,它作为主视图控制器和第二个视图控制器创建为带有xib文件的UIViewController子类.
我在主控制器上放了一个按钮来显示第二个控制器:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func testVCBtnTapped() {
let vc = TestVC()
presentViewController(vc, animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
Run Code Online (Sandbox Code Playgroud)
}
我运行应用程序并按下按钮显示第二个控制器 - 一切都很好
转到xcode beta 5,我运行应用程序,当我按下按钮时,屏幕变黑.
因为我知道他们搞砸了init代码,所以我尝试使用覆盖来查看它会修复它:
class TestVC: UIViewController {
override init() {
super.init()
}
required init(coder aDecoder: NSCoder!) {
super.init(coder: …Run Code Online (Sandbox Code Playgroud) 我正在尝试播放系统声音.使用Xcode 6 Beta 4.这是代码:
func playKeyClick()
{
let filePath = NSBundle.mainBundle().pathForResource("Tock", ofType: "aiff")
if NSFileManager.defaultManager().fileExistsAtPath(filePath) {
println("file exists")
}
let fileURL = NSURL(fileURLWithPath: filePath)
var soundID:SystemSoundID = 0
AudioServicesCreateSystemSoundID(fileURL, &soundID)
AudioServicesPlaySystemSound(soundID)
}
Run Code Online (Sandbox Code Playgroud)
它在设备上工作正常但不能在模拟器中播放.我已经创建了一个测试应用程序除了播放这个声音之外什么都不做,所以我认为我没有做任何事情来阻止它.
模拟器从Safari应用程序播放声音确定,所以我认为它显示它能够从我的应用程序播放声音.
请注意,我还有其他两种用于播放声音的代码,这两种方式也适用于设备但不适用于模拟器.我选择这个例子是为了简单.
编辑 - 将文件更改为资源包以避免混淆
我在xcode 7 beta 5中有一个swift 2.0项目,想要使用ReactiveCocoa 3.0.
我已经能够为xcode 6.3和swift 1.2设置一个项目,但无法弄清楚如何为xcode 7和swift2做到这一点
有一个swift2分支,但我发现的每个方法都只是在主分支中调用.
清晰的一步一步说明会非常棒.