我想把一个Button上的标题设置为左边.但我尝试的一切都没有用.
附:
UILabelButton.titleLabel.textAlignment = .Left
Run Code Online (Sandbox Code Playgroud)
要么:
UILabelButton.contentVerticalAlignment = UIControlContentVerticalAlignment // There is no left
Run Code Online (Sandbox Code Playgroud)
按钮标题仍然居中.
还有其他房产吗?
在XCode 7.3.x中,我使用以下命令更改了StatusBar的背景颜色:
func setStatusBarBackgroundColor(color: UIColor) {
guard let statusBar = UIApplication.sharedApplication().valueForKey("statusBarWindow")?.valueForKey("statusBar") as? UIView else {
return
}
statusBar.backgroundColor = color
}
Run Code Online (Sandbox Code Playgroud)
但似乎这不再适用于Swift 3.0.
我尝试过:
func setStatusBarBackgroundColor(color: UIColor) {
guard let statusBar = (UIApplication.shared.value(forKey: "statusBarWindow") as AnyObject).value(forKey: "statusBar") as? UIView else {
return
}
statusBar.backgroundColor = color
}
Run Code Online (Sandbox Code Playgroud)
但它给了我:
this class is not key value coding-compliant for the key statusBar.
Run Code Online (Sandbox Code Playgroud)
任何想法如何使用XCode8/Swift 3.0进行更改?
是否有可能从具有特定属性的数组中获取对象?或者我是否需要循环遍历我的数组中的所有对象并检查属性是否是我正在寻找的特定属性?
编辑:感谢您给我正确的方向,但我有一个问题转换它.
//再次编辑:好的,如果只有一个特定的结果?这也是一种可行的方法吗?
let imageUUID = sender.imageUUID
let questionImageObjects = self.formImages[currentSelectedQuestion.qIndex] as [Images]!
// this is working
//var imageObject:Images!
/*
for (index, image) in enumerate(questionImageObjects) {
if(image.imageUUID == imageUUID) {
imageObject = image
}
}
*/
// this is not working - NSArray is not a subtype of Images- so what if there is only 1 possible result?
var imageObject = questionImageObjects.filter( { return $0.imageUUID == imageUUID } )
Run Code Online (Sandbox Code Playgroud) 我有弹出窗口的问题.如果我点击一个单元格,我将加载一个弹出框以选择更多细节.一切正常,但当我再次按下我的手机时,我每次都收到以下信息:
警告:尝试在MainTableViewController上呈现ModalTableViewController ...已经呈现(null)
如果我点击另一个单元格,我将不会收到此警告.仅当再次点击同一行时.
我尝试了很多东西,但我无法解决这个问题.我像这样加载我的popover:
var popover: UIPopoverController!
var popoverContent: ModalTableViewController!
Run Code Online (Sandbox Code Playgroud)
在我的手机上点击:
popoverContent = self.storyboard.instantiateViewControllerWithIdentifier("ModalTableViewController") as ModalTableViewController
popoverContent.selectedQuestionID = indexPath!.row
popover = UIPopoverController(contentViewController: popoverContent)
popover.delegate = self
popover.presentPopoverFromRect(currentCell.LabelCellTitle.frame, inView: currentCell.LabelCellTitle.superview, permittedArrowDirections: UIPopoverArrowDirection.Left, animated: true)
Run Code Online (Sandbox Code Playgroud)
并解雇
func popoverControllerDidDismissPopover(popoverController: UIPopoverController!) {
popover.dismissPopoverAnimated(false) // just to check
self.popover = nil
self.popoverContent = nil
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
编辑:
如果我检查:
if(self.popoverContent == nil) {
Run Code Online (Sandbox Code Playgroud)
在打开它之前,我会发现当我再次敲击同一个细胞时它不是零.
再次编辑:
如果我使用一些不同的设置创建它,我会遇到同样的问题:
自定义1x1px按钮.用popue连接popover.在单元格点击移动按钮到单元格并打开弹出窗口.
所以没有用于打开popover的代码,只有storyboard编辑器.
我得到相同的错误消息(有时),如果我再次点击相同的弹出窗口.
当我尝试更新到Xcode 8.3时,App Store中发生了以下情况(已经过了一个多小时):
所以它只是说"加载"而没有任何反应.
我已经尝试过的:
有任何想法吗?
顺便说一句:我的Apple会员资格在5天后到期 - 这可能是个问题吗?
我有一个核心数据对象,我有2个Fieds(一个字符串(GUID)和一个我想用作过滤器的Int)
所以在SQL中它将是"SELECT*FROM Answers WHERE qIndex = 1 AND GUID = '88bfd206-82fb-4dd0-b65d-096f8902855c'
我已尝试使用Core Data,但我无法使用字符串值进行过滤.
这是我的代码
var request = NSFetchRequest(entityName: "Answers")
request.returnsObjectsAsFaults = false;
let resultPredicate1 = NSPredicate(format: "qIndex = %i", qIndex)
let resultPredicate2 = NSPredicate(format: "formUUID = %s", formUUID)
var compound = NSCompoundPredicate.andPredicateWithSubpredicates([resultPredicate1, resultPredicate2])
request.predicate = compound
var results:NSArray = context.executeFetchRequest(request, error: nil)
Run Code Online (Sandbox Code Playgroud)
任何想法我在做什么错?使用相同的代码和2个整数值筛选它工作正常.
提前致谢
我想更新到Xcode 8,但是当我启动App Store时它只显示一个Open按钮,但我现有的版本是7.3.1
要求应该是El Capitan 10.11.5 - 我安装了10.11.6.
为什么没有Update按钮?
如何检查是否在Core Data Object中设置了属性?
我将所有核心数据对象加载到目录中:
var formQuestions = [Questions]()
Run Code Online (Sandbox Code Playgroud)
我的核心数据NSManagementObject是:
@NSManaged var noticeText: String
Run Code Online (Sandbox Code Playgroud)
formQuestions [indexPath.row] .noticeText
//加载:
var fetchRequest = NSFetchRequest(entityName: "Questions")
fetchRequest.predicate = NSPredicate(format: "forms = %@", currentForm!)
formQuestions = context.executeFetchRequest(fetchRequest, error: nil) as [Questions]
Run Code Online (Sandbox Code Playgroud)
我的属性"noticeText"可能是空的或不是,所以当我创建我的核心数据对象时,可能无法设置某些值.(该属性在Core Data中设置为可选)
当我现在尝试证明是否有值时,它总是给我带来"EXC_BAD_ACCESS ......"
if(formQuestions[indexPath.row].noticeText.isEmpty == false)
Run Code Online (Sandbox Code Playgroud)
我在创建核心数据对象时可以设置一个空字符串,但这应该不是一个好的解决方案.
那么如何检查(optinal)和未设置的值是否存在?
提前致谢.
我已经为这个问题找到了一些解决方案(这是因为仍然有一个活动的动画引起的).
但是在iPad应用程序上使用UIDocumentInteractionController时,我无法在我的应用程序中解决这个问题.
我的ViewController看起来像
MainViewController - > ContainerView
在这个ContainerView我有一个侧边栏,从这个SideBar我想打开一个UIDocumentInteractionController.
我使用NSNotification,因为这个"MainViewController"应该处理来自不同视图的多个文件.
所以:(这是在我的MainViewController中)
func openFile(notification: NSNotification){
fileUrl = notification.object as NSURL
var documentInteractionController = UIDocumentInteractionController(URL: self.fileUrl!)
documentInteractionController.delegate = self
documentInteractionController.presentPreviewAnimated(false)
}
func documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) -> UIViewController {
return self
}
Run Code Online (Sandbox Code Playgroud)
但生病总是得到以下错误:
警告:对QLRemotePreviewContentController的开始/结束外观转换的不平衡调用
我不知道为什么?应该没有动画,如果我打开另一个(模态)窗口,这里没有警告.
如果我使用延迟(例如5秒!),则会出现此警告.
编辑:发现我可能是我的ContainerView的问题.当我包含"ViewWillDissapear"和"ViewDidDisappear"时,我在这里得到错误:
view will dissappear
Unbalanced calls to begin/end appearance transitions for <QLRemotePreviewContentController: 0x7d35d400>
viww Did dissapaer
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?提前致谢