小编Ash*_*ale的帖子

Xcode 6中的PCH文件

在我以前的项目中,我可以.pch在Supporting Files下找到该文件.

但现在在Xcode 6中,我找不到任何.pch文件.我应该采取任何措施来制作这个文件吗?

pch xcode6

181
推荐指数
4
解决办法
7万
查看次数

PCL将图像文件保存到本地文件系统

我在寻找一种方式来存储使用我的本地文件系统的图像文件PCL存储插件在我的核心项目Windows Phone,Xamarin.Android以及Xamarin.iOS.但是,插件只提供了编写Text的方法.什么关于字节.有没有办法保存字节数组?

storage cross-platform portable-class-library xamarin

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

使用WKHTTPCookieStore删除cookie

我正在使用新WKHTTPCookieStore类,以便WKWebViews在应用程序中注入和删除cookie .

所有WKWebViews共享都是共同的,WKWebViewConfiguration以便他们可以共享一个共同的cookie商店.

使用该add()方法注入cookie工作正常,每个Web视图都可以看到新的cookie并发送它们的请求.删除cookie似乎是一个问题 - 网络视图仍然看到所谓的已删除的cookie,并继续发送每个请求:

let cookieStore = self.webkitConfiguration.websiteDataStore.httpCookieStore
cookieStore.getAllCookies { (cookies) in
    for cookie:HTTPCookie in cookies {
        if cookie.name == "CookieIWantToDelete" {
            cookieStore.delete(cookie, completionHandler: {
                self.webView.reload() //Deleted cookie is still sent with this request
            })
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以通过废弃所有的饼干来解决它WKWebsiteDataStore,但它似乎有点矫枉过正.

有任何想法吗?

cocoa-touch webkit ios swift

8
推荐指数
1
解决办法
879
查看次数

UIAlertController没有消失

我没有弄到我的代码有什么问题.我只是用"确定"按钮显示警报,当用户点击"确定"时,警报就应该开始.但它并没有消失.使用Swift3进行编程.viewDidAppear()这个代码是正确的地方吗?或者我做错了什么?

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    let alertController = UIAlertController(title: "Wrong Item", message: "Could not find details of an item.", preferredStyle: .alert)          
    alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
    present(alertController, animated: true, completion: nil)  
}
Run Code Online (Sandbox Code Playgroud)

更新:当我将相同的代码放在其他控制器中时,它工作.在原始控制器中,在viewDidLoad()中,我有一个Async如下调用.这是因为这个问题吗?

DispatchQueue.global(qos: .background).async {
    self.getDetails(onCompletion: {(json: JSON) in

    let dict = self.convertToDictionary(text: json.stringValue)

        DispatchQueue.main.async {

            self.activityIndicator.stopAnimating()
            UIApplication.shared.endIgnoringInteractionEvents()

            //Other UI update operation

        }
    })
}    
Run Code Online (Sandbox Code Playgroud)

我还覆盖viewWillDisappear()viewWillAppear(),只需设定屏幕的标题.

viewdidappear ios uialertcontroller swift3

6
推荐指数
2
解决办法
628
查看次数

用于音乐节目的TabBarController

tabBarController用来创建一个音乐程序,我有如gif所示的如何操作的问题

问题:

  1. 怎么做,当你点击tabBarItem时," presentViewController"工作

  2. 如何使照片不会改变颜色并使其变圆,仅在第三个 tabBarItem

    最好没有库

在此输入图像描述

它应该是

在此输入图像描述

我的TabBarController

override func viewDidLoad() {
     super.viewDidLoad()

    self.delegate = self

    // ?????? ???? ???? tabBar
    self.tabBar.barTintColor = .white

    // ?????? ???? UITabBarItem and Title
    UITabBar.appearance().tintColor = UIColor(hex: 0x0077fe, alpha: 1)

    //?????? ???? background UITabBar
    UITabBar.appearance().barTintColor = UIColor.white


    // ?????? ??? ?????
    for item in self.tabBar.items! {
        if let image = item.image {
            item.image = image.withRenderingMode(.alwaysOriginal)

        }
    }

    //?????????? ? ????????? ? ???????????
    let storyBoard = UIStoryboard(name: "Main", bundle:nil)
    let controller1 …
Run Code Online (Sandbox Code Playgroud)

tabbar uitabbarcontroller uitabbaritem ios swift

6
推荐指数
1
解决办法
167
查看次数

如何计算一个不接触UIView的随机CGPoint

这是一个示例视图:

在此输入图像描述

我想计算一个框架CGPoint,我可以在那里生成另一张卡片(UIView)而不触及任何现有的卡片.当然,它是可选的,因为视图可以充满卡片,因此没有免费的地方.

这就是我在屏幕上看到任何卡片以及我的功能现在如何:

func freeSpotCalculator() -> CGPoint?{
    var takenSpots = [CGPoint]()
    for card in playableCards{
        takenSpots.append(card.center)
    }

}
Run Code Online (Sandbox Code Playgroud)

我不知道从哪里开始以及如何CGPoint在屏幕上计算随机数.随机帧具有相同的widthheight为屏幕上的卡片英寸

math uiview ios swift

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

iOS AVAudioSession,如何访问AVAudioRecorder音频电平表

我正在使用供应商的框架,其中移动应用程序中的音频录制是从何处启动的AVAudioSession,但无法找到任何地方AVAudioRecorder来启动音频电平表并显示在主屏幕上。

有什么提示或建议如何实现这一目标吗?如何获取当前麦克风电平AVAudioSession

这是正在使用的代码:

[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {

    if (granted) {
        dispatch_async(self.audioSessionQueue, ^{
            NSError *error;
            [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:&error];
            [[AVAudioSession sharedInstance] setActive:YES error:&error];

            self.audioCaptureSession = [[AVCaptureSession alloc] init];
            [self.audioCaptureSession beginConfiguration];
AVCaptureDevice *audioCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
            AVCaptureDeviceInput *audioCaptureDeviceInput = [AVCaptureDeviceInput deviceInputWithDevice:audioCaptureDevice error:&error];

    if ([self.audioCaptureSession canAddInput:audioCaptureDeviceInput])
            {
                [self.audioCaptureSession addInput:audioCaptureDeviceInput];
            }
    else
            {
                NSLog(@"Couldn't add audio capture device input.");

                [self.audioCaptureSession commitConfiguration];
                return;
            }

            [self.audioCaptureReader setResultsDelegate:self queue:dispatch_get_main_queue()];
            [self.audioCaptureSession addOutput:self.audioCaptureReader.captureOutput];

[self.audioCaptureSession commitConfiguration];
[self.audioCaptureSession startRunning];
}
Run Code Online (Sandbox Code Playgroud)

avfoundation ios avaudiosession

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

在Xcode 8中创建.xib启动屏幕

我正在尝试使用Xcode 8在较旧的iOS应用程序中创建启动屏幕.我需要.xib启动屏幕,但Xcode正在创建Launch Screen.storyboard.有人可以建议吗.

先感谢您.

ios launch-screen xcode8

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