由于我的应用得到了所有方向的支持.我想只将肖像模式锁定到特定的UIViewController.
(例如,假设它是Tabbed应用程序,当SignIn View以模态方式出现时,我只想将SignIn View设置为纵向模式,无论用户如何旋转设备或当前设备方向如何)
我的问题是,是否有可能让UIView显示图像,如果有,我怎么做呢?我所能找到的是colorwithpatternImage不再适用于swift的东西.
我现在尝试使用的代码是:
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
Run Code Online (Sandbox Code Playgroud)
提前感谢您的回答!
任何帮助请我等了这么久,它没有给我任何改善.仍然坚持 Updating local specs repositories
实际上我正在尝试更新我在xcode上使用的库的pod文件.我昨天关闭它因为它需要太长时间.今天我再次control + c运行,pod install再次运行.
它不起作用,坚持不懈 Updating local specs repositories
当我打开我的Xcode时,由于pod问题会发生许多错误.
我需要帮助!
我试图弄清楚如何在我UIPickerView上次选择后打开时显示所选行.
当我再次打开PickerView时,我想让我UIPickerView设置上次选择的选定行.
Swift有什么办法吗?
我的表视图单元格有问题.使用带有嵌入式导航控制器的segue从详细视图返回到主表视图后,我无法禁用表格单元格选择的突出显示.表单元格仍处于选中状态.当我单击其中一个以显示详细信息时,我不希望禁用表格单元格选择.我只想在从详细信息视图返回后禁用它们.
我已经为我的发行版创建了应用程序ID和配置文件.当我使用分发配置文件存档或构建我的应用程序时,我收到以下错误
PhaseScriptExecution Embed\ Pods\ Frameworks /Users/Htarwara6245/Library/Developer/Xcode/DerivedData/HSSECrix-cgteuxpjvsdrnhdqwjbwqyoqsqpc/Build/Intermediates/HSSECrix.build/Debug-iphoneos/HSSECrix.build/Script-FB973BA3854BA671C46AFE96.sh
cd /Users/Htarwara6245/Documents/workspace/iOS/HSSECrix
/bin/sh -c /Users/Htarwara6245/Library/Developer/Xcode/DerivedData/HSSECrix-cgteuxpjvsdrnhdqwjbwqyoqsqpc/Build/Intermediates/HSSECrix.build/Debug-iphoneos/HSSECrix.build/Script-FB973BA3854BA671C46AFE96.sh
mkdir -p /Users/Htarwara6245/Library/Developer/Xcode/DerivedData/HSSECrix-cgteuxpjvsdrnhdqwjbwqyoqsqpc/Build/Products/Debug-iphoneos/HSSECrix.app/Frameworks
rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "/Users/Htarwara6245/Library/Developer/Xcode/DerivedData/HSSECrix-cgteuxpjvsdrnhdqwjbwqyoqsqpc/Build/Products/Debug-iphoneos/Alamofire.framework" "/Users/Htarwara6245/Library/Developer/Xcode/DerivedData/HSSECrix-cgteuxpjvsdrnhdqwjbwqyoqsqpc/Build/Products/Debug-iphoneos/HSSECrix.app/Frameworks"
building file list ... done
Alamofire.framework/
Alamofire.framework/Alamofire
Alamofire.framework/Info.plist
Alamofire.framework/_CodeSignature/
Alamofire.framework/_CodeSignature/CodeResources
sent 1203761 bytes received 98 bytes 2407718.00 bytes/sec
total size is 1203264 speedup is 1.00
Code Signing /Users/Htarwara6245/Library/Developer/Xcode/DerivedData/HSSECrix-cgteuxpjvsdrnhdqwjbwqyoqsqpc/Build/Products/Debug-iphoneos/HSSECrix.app/Frameworks/Alamofire.framework with Identity iPhone Distribution: xxxx (28J87M7DQU)
/usr/bin/codesign --force --sign 7EC847A7363D5591F3061E94631865E1EB36D1D7 --preserve-metadata=identifier,entitlements "/Users/Htarwara6245/Library/Developer/Xcode/DerivedData/HSSECrix-cgteuxpjvsdrnhdqwjbwqyoqsqpc/Build/Products/Debug-iphoneos/HSSECrix.app/Frameworks/Alamofire.framework"
7EC847A7363D5591F3061E94631865E1EB36D1D7: …Run Code Online (Sandbox Code Playgroud) 错误:无法为UIMainStoryboardFile"Main"实例化默认视图控制器 - 可能未设置指定的入口点?
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x7ff949770c30>) doesn't contain a view controller with identifier 'CenterViewController''
Run Code Online (Sandbox Code Playgroud)
我不知道我的主故事板有什么问题.我正在构建我自己的滑出式导航面板.
CenterViewController.swift
import UIKit
@objc
protocol CenterViewControllerDelegate {
optional func toggleLeftPanel()
optional func collapseSidePanels()
}
class CenterViewController: UIViewController, SideMenuPanelViewControllerDelegate {
//@IBOutlet weak private var testimageView: UIImageView!
@IBOutlet weak private var testLabel:UILabel!
var delegate: CenterViewControllerDelegate?
// MARK: Button actions
@IBAction func MenuTapped(sender: AnyObject) {
delegate?.toggleLeftPanel?()
}
func localSelected(local: LocalMenus) {
//imageView.image = animal.image
testLabel.text = local.title
delegate?.collapseSidePanels?()
}
/* …Run Code Online (Sandbox Code Playgroud) 我在桌面视图中获得了许多发票文件列表以及每个单元格中的许多下载按钮.当我单击其中一个时,它将下载发票文件.但问题是服务器响应建议文件名是"发票". pdf"在我下载的每个文件中.因此,我需要手动编辑文件名,然后在下载后保存到文档.所以,如何在成功下载后手动编辑文件名,并将其作为临时文件保存在文档中使用Alamofire.Request.suggestedDownloadDestination.
这是我的下载功能.
func downloadInvoice(invoice: Invoice, completionHandler: (Double?, NSError?) -> Void) {
guard isInvoiceDownloaded(invoice) == false else {
completionHandler(1.0, nil) // already have it
return
}
let params = [
"AccessToken" : “xadijdiwjad12121”]
// Can’t use the destination file anymore because my server only return one file name “invoice.pdf” no matter which file i gonna download
// So I have to manually edit my file name which i saved after it was downloaded.
let destination = Alamofire.Request.suggestedDownloadDestination(directory: .DocumentDirectory, …Run Code Online (Sandbox Code Playgroud) 我曾经在领域数据库中插入远程通知数据.但是,问题是,我发送的每个通知content-available = 1都意味着每次通知都来自didReceiveRemoteNotifications工作,并且当用户点击或不通知时保存静默通知.所以,如果我的应用程序在后台,将有两个记录插入.
第一个条件是当应用程序处于后台时发出通知,didReceiveRemoteNotification因为content-available = 1并且插入一条记录而被调用.
因此,第二个条件是如果用户在通知中心内点击通知,该方法didReceiveRemoteNotification再次工作并插入相同的记录.因此,重复问题.
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler handler: (UIBackgroundFetchResult) -> Void) {
if let aps = userInfo["aps"] as? NSDictionary{
if let alert = aps["alert"] as? NSDictionary{
if let mbody = alert["body"] as? String{
print("Message Body : \(body)")
body = mbody
}
if let mtitle = alert["title"] as? String{
print("Message Title : \(title)")
title = mtitle
}
}
}
let newNotification = NotificationList()
newNotification.title …Run Code Online (Sandbox Code Playgroud) 我试图从使用正则表达式的html字符串获取我目前正在处理的是:
extension String {
func regex (pattern: String) -> [String] {
do {
let regex = try NSRegularExpression(pattern: pattern, options: NSRegularExpressionOptions(rawValue: 0))
let nsstr = self as NSString
let all = NSRange(location: 0, length: nsstr.length)
var matches : [String] = [String]()
regex.enumerateMatchesInString(self, options: NSMatchingOptions(rawValue: 0), range: all) {
(result : NSTextCheckingResult?, _, _) in
if let r = result {
let result = nsstr.substringWithRange(r.range) as String
matches.append(result)
}
}
return matches
} catch {
return [String]()
}
}
Run Code Online (Sandbox Code Playgroud)
而且模式是: <img[^>]+src\\s*=\\s*['\']([^'\"]+)['\"][^>]*> …