小编Mus*_*ari的帖子

无法将“新群组”重命名为“我的群组”。在Xcode10.2中

我刚刚创建了一个群组,想要重命名它,但是无法更新弹出窗口。我知道如何从finder中重命名它。但是y Xcode 10.2中的Apple不允许直接从Xcode使用它吗?

要么

我想念什么吗? 在此处输入图片说明

xcode

29
推荐指数
3
解决办法
6158
查看次数

在Swift中过滤字典数组

我有一个带字典的数组示例:

(
        {
        Email = "kate-bell@mac.com";
        Name = "Kate Bell";
        Number = "(555) 564-8583";
    },
        {
        Email = "d-higgins@mac.com";
        Name = "Daniel Higgins";
        Number = "555-478-7672";
    }
)
Run Code Online (Sandbox Code Playgroud)

我想根据密钥"名称"过滤这个字典

 func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
    let predicate = NSPredicate(format:"Name == %@", searchText)
    let filteredArray = (arrContact as NSMutableArray).filteredArrayUsingPredicate(predicate)
    print(filteredArray)
    if(filteredArray.count == 0){
                searchActive = false;
            } else {
                searchActive = true;
            }
            tblData.reloadData()
 }
Run Code Online (Sandbox Code Playgroud)

我总是从上面的swift代码得到空数组.请帮我解决这个问题.谢谢

nsmutablearray uisearchbar nsmutabledictionary nspredicate swift2

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

如何从UITableViewCell获取文本字段的值?

所以我有这个UITableView单元格有4个UITextField,我想在按钮点击时得到它们的值.

此代码不检索任何值.

@IBAction func printBtnAction(_ sender: Any) {

    let cell = self.myTableView.dequeueReusableCell(withIdentifier: "manualAddC1") as! AddFriendC1Cell

    let alias = cell.aliasTextField.text!
    let primaryPhone = cell.primaryPhoneTextField.text!
    let secondaryPhone = cell.seondaryPhoneTextField.text!
    let email = cell.emailAddressTextField.text!

    print("Alias: \(alias), Phone: \(primaryPhone), Phone2: \(secondaryPhone), Email: \(email)")
}
Run Code Online (Sandbox Code Playgroud)

这是TableView的屏幕截图 在此输入图像描述

xcode uitableview swift swift3

3
推荐指数
2
解决办法
2万
查看次数

将AVPlayerViewController放在UIView中

目前我正在使用底部有四个控件的对话视图.每个控件都在对话框中加载不同的视图.其中一个控件是AVPlayer在对话视图中设置并正在播放它.不幸的是,AVPlayer它本身没有播放控件.

AVPlayerViewController怎么过确实有播放控制.是否有可能将一个 AVPlayerViewController 内部的 UIView ,这样它不会开始作为一个新的屏幕? 我想把它放在我的内部,UIView所以一切都发生在我的拨号内.

ios avplayer swift avplayerviewcontroller swift3

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

如何使用Alamofire Image在swift中添加UIActivity指示器

我正在使用AlamofireImage库,我想subview在ImageView上添加一个(UIActivityIndi​​cator),直到图像没有下载.但不知道该怎么做.

self.imgView_main.af_setImageWithURL(downloadURL)
Run Code Online (Sandbox Code Playgroud)

图像正在下载.但如何表明UIActivityIndicator请帮助我

swift alamofireimage

2
推荐指数
1
解决办法
1330
查看次数

将扩展转换为类的功能

我有扩展名将html符号转换为字符串:

extension String {
    func convertHtmlSymbols() throws -> String? {
        guard let data = data(using: .utf8) else { return nil }
        return try NSAttributedString(data: data, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: String.Encoding.utf8.rawValue], documentAttributes: nil).string
    }        
}
Run Code Online (Sandbox Code Playgroud)

这个扩展很好.但是我需要将此扩展转换为类"Converter"中的函数:

class Converter{

    func convertHtmlSymbols(data: String) throws -> String? {
        guard let data = data(using: .utf8) else { return nil }
        return try NSAttributedString(data: data, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: String.Encoding.utf8.rawValue], documentAttributes: nil).string
    }
}
Run Code Online (Sandbox Code Playgroud)

但我得到了这个错误:

错误:无法调用非函数类型的值

ios swift swift3

0
推荐指数
1
解决办法
94
查看次数

在iOS应用中显示通知当应用程序在前景/活动在swift 3

我正在尝试在应用处于活动状态时显示横幅通知.我使用了给定的方法但没有结果,横幅通知仅在应用关闭时出现:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
    print("Push notification received: \(userInfo)")

    if application.applicationState == .active {
       print("active")
       let localNotification = UILocalNotification()
       localNotification.userInfo = userInfo
       localNotification.alertAction = "Test"
       localNotification.soundName = UILocalNotificationDefaultSoundName
       localNotification.alertBody = "Notification test!!"
       localNotification.fireDate = Date()
       UIApplication.shared.scheduleLocalNotification(localNotification)
     }
}
Run Code Online (Sandbox Code Playgroud)

它打印"活动"但通知未显示.我错过了任何一步吗?

谢谢.

push-notification apple-push-notifications ios swift

0
推荐指数
1
解决办法
6257
查看次数

如何更改UIViewController的背景颜色

我有一个MainViewController,它有一个容器视图.边缘边缘很少.
现在我导航到另一个视图ViewController1.假设我在ViewController1中的某个区域出现错误.然后我想用红色改变我的MainViewController的背景.因此视图应如下所示(屏幕截图已附加),其中红色边框为MainViewController背景

在此输入图像描述

这是我的代码

class ViewController1: UIViewController {
var MainVC =  MainViewController()
     override func viewDidLoad() {
        super.viewDidLoad()
        MainVC.view.backgroundColor = UIColor.redColor()
    }
Run Code Online (Sandbox Code Playgroud)

但它不起作用

iphone ios uicontainerview swift

-1
推荐指数
1
解决办法
5408
查看次数