- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在我的 Objective c 应用程序中使用了 TPKeyboardAvoiding scrollview。现在我想在我的 swift 项目中使用它。我进行了搜索,但没有找到具体的步骤。
感谢帮助
最佳答案
Swift 4.1,只需将类相应地分配给 Storyboard或 xib 中的 ScrollView 即可。
// MARK: - TableView
class TPKeyboardAvoidingTableView:UITableView,UITextFieldDelegate, UITextViewDelegate {
override var frame:CGRect{
willSet{
super.frame = frame
}
didSet{
if hasAutomaticKeyboardAvoidingBehaviour() {return}
TPKeyboardAvoiding_updateContentInset()
}
}
override var contentSize:CGSize{
willSet(newValue){
if hasAutomaticKeyboardAvoidingBehaviour() {
super.contentSize = newValue
return
}
if newValue.equalTo(self.contentSize)
{
return
}
super.contentSize = newValue
self.TPKeyboardAvoiding_updateContentInset()
}
// didSet{
// self.TPKeyboardAvoiding_updateContentInset()
// }
}
override init(frame: CGRect, style: UITableViewStyle) {
super.init(frame: frame, style: style)
self.setup()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.setup()
}
override func awakeFromNib() {
setup()
}
deinit{
NotificationCenter.default.removeObserver(self)
}
func hasAutomaticKeyboardAvoidingBehaviour()->Bool
{
if #available(iOS 8.3, *) {
if self.delegate is UITableViewController
{
return true
}
}
return false
}
func focusNextTextField()->Bool
{
return self.TPKeyboardAvoiding_focusNextTextField()
}
@objc func scrollToActiveTextField()
{
return self.TPKeyboardAvoiding_scrollToActiveTextField()
}
override func willMove(toSuperview newSuperview: UIView?) {
super.willMove(toSuperview: newSuperview)
if newSuperview != nil {
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), object: self)
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
self.TPKeyboardAvoiding_findFirstResponderBeneathView(self)?.resignFirstResponder()
super.touchesEnded(touches, with: event)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if !self.focusNextTextField()
{
textField.resignFirstResponder()
}
return true
}
override func layoutSubviews() {
super.layoutSubviews()
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), object: self)
Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), userInfo: nil, repeats: false)
}
}
private extension TPKeyboardAvoidingTableView
{
func setup()
{
if self.hasAutomaticKeyboardAvoidingBehaviour() { return }
NotificationCenter.default.addObserver(self,
selector: #selector(TPKeyboardAvoiding_keyboardWillShow(_:)),
name: NSNotification.Name.UIKeyboardWillChangeFrame,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(TPKeyboardAvoiding_keyboardWillHide(_:)),
name: NSNotification.Name.UIKeyboardWillHide,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(scrollToActiveTextField),
name: NSNotification.Name.UITextViewTextDidBeginEditing,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(scrollToActiveTextField),
name: NSNotification.Name.UITextFieldTextDidBeginEditing,
object: nil)
}
}
// MARK: - CollectionView
class TPKeyboardAvoidingCollectionView:UICollectionView,UITextViewDelegate {
override var contentSize:CGSize{
willSet(newValue){
if newValue.equalTo(self.contentSize)
{
return
}
super.contentSize = newValue
self.TPKeyboardAvoiding_updateContentInset()
}
}
override var frame:CGRect{
willSet{
super.frame = frame
}
didSet{
self.TPKeyboardAvoiding_updateContentInset()
}
}
// override init(frame: CGRect) {
// super.init(frame: frame)
// }
override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: frame, collectionViewLayout: layout)
setup()
}
required init?(coder aDecoder: NSCoder) {
// fatalError("init(coder:) has not been implemented")
super.init(coder: aDecoder)
self.setup()
}
override func awakeFromNib() {
setup()
}
deinit{
NotificationCenter.default.removeObserver(self)
}
func focusNextTextField()->Bool
{
return self.TPKeyboardAvoiding_focusNextTextField()
}
@objc func scrollToActiveTextField()
{
return self.TPKeyboardAvoiding_scrollToActiveTextField()
}
override func willMove(toSuperview newSuperview: UIView?) {
super.willMove(toSuperview: newSuperview)
if newSuperview != nil {
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), object: self)
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
self.TPKeyboardAvoiding_findFirstResponderBeneathView(self)?.resignFirstResponder()
super.touchesEnded(touches, with: event)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if !self.focusNextTextField()
{
textField.resignFirstResponder()
}
return true
}
override func layoutSubviews() {
super.layoutSubviews()
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), object: self)
Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), userInfo: nil, repeats: false)
}
}
private extension TPKeyboardAvoidingCollectionView
{
func setup()
{
NotificationCenter.default.addObserver(self,
selector: #selector(TPKeyboardAvoiding_keyboardWillShow(_:)),
name: NSNotification.Name.UIKeyboardWillChangeFrame,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(TPKeyboardAvoiding_keyboardWillHide(_:)),
name: NSNotification.Name.UIKeyboardWillHide,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(scrollToActiveTextField),
name: NSNotification.Name.UITextViewTextDidBeginEditing,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(scrollToActiveTextField),
name: NSNotification.Name.UITextFieldTextDidBeginEditing,
object: nil)
}
}
// MARK: - ScrollView
class TPKeyboardAvoidingScrollView:UIScrollView,UITextFieldDelegate,UITextViewDelegate
{
override var contentSize:CGSize{
didSet{
self.TPKeyboardAvoiding_updateFromContentSizeChange()
}
}
override var frame:CGRect{
didSet{
self.TPKeyboardAvoiding_updateContentInset()
}
}
override init(frame: CGRect) {
super.init(frame: frame)
self.setup()
}
override func awakeFromNib() {
setup()
}
func contentSizeToFit()
{
self.contentSize = self.TPKeyboardAvoiding_calculatedContentSizeFromSubviewFrames()
}
func focusNextTextField() ->Bool
{
return self.TPKeyboardAvoiding_focusNextTextField()
}
@objc func scrollToActiveTextField()
{
return self.TPKeyboardAvoiding_scrollToActiveTextField()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.setup()
}
deinit{
NotificationCenter.default.removeObserver(self)
}
override func willMove(toSuperview newSuperview: UIView?) {
super.willMove(toSuperview: newSuperview)
if newSuperview != nil {
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), object: self)
}
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
self.TPKeyboardAvoiding_findFirstResponderBeneathView(self)?.resignFirstResponder()
super.touchesEnded(touches, with: event)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if !self.focusNextTextField()
{
textField.resignFirstResponder()
}
return true
}
override func layoutSubviews() {
super.layoutSubviews()
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), object: self)
Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_:)), userInfo: nil, repeats: false)
}
}
private extension TPKeyboardAvoidingScrollView
{
func setup()
{
NotificationCenter.default.addObserver(self,
selector: #selector(TPKeyboardAvoiding_keyboardWillShow(_:)),
name: NSNotification.Name.UIKeyboardWillChangeFrame,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(TPKeyboardAvoiding_keyboardWillHide(_:)),
name: NSNotification.Name.UIKeyboardWillHide,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(scrollToActiveTextField),
name: NSNotification.Name.UITextViewTextDidBeginEditing,
object: nil)
NotificationCenter.default.addObserver(self,
selector: #selector(scrollToActiveTextField),
name: NSNotification.Name.UITextFieldTextDidBeginEditing,
object: nil)
}
}
// MARK: - Process Event
let kCalculatedContentPadding:CGFloat = 10;
let kMinimumScrollOffsetPadding:CGFloat = 20;
extension UIScrollView
{
@objc func TPKeyboardAvoiding_keyboardWillShow(_ notification:Notification)
{
guard let userInfo = notification.userInfo else { return }
guard let rectNotification = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue else
{
return
}
let keyboardRect = self.convert(rectNotification.cgRectValue , from: nil)
if keyboardRect.isEmpty
{
return
}
let state = self.keyboardAvoidingState()
guard let firstResponder = self.TPKeyboardAvoiding_findFirstResponderBeneathView(self) else { return}
state.keyboardRect = keyboardRect
if !state.keyboardVisible
{
state.priorInset = self.contentInset
state.priorScrollIndicatorInsets = self.scrollIndicatorInsets
state.priorPagingEnabled = self.isPagingEnabled
}
state.keyboardVisible = true
self.isPagingEnabled = false
if self is TPKeyboardAvoidingScrollView
{
state.priorContentSize = self.contentSize
if self.contentSize.equalTo(CGSize.zero)
{
self.contentSize = self.TPKeyboardAvoiding_calculatedContentSizeFromSubviewFrames()
}
}
let duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as? Float ?? 0.0
let curve = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? Int ?? 0
let options = UIViewAnimationOptions(rawValue: UInt(curve))
UIView.animate(withDuration: TimeInterval(duration),
delay: 0,
options: options,
animations: { [weak self]() -> Void in
if let actualSelf = self
{
actualSelf.contentInset = actualSelf.TPKeyboardAvoiding_contentInsetForKeyboard()
let viewableHeight = actualSelf.bounds.size.height - actualSelf.contentInset.top - actualSelf.contentInset.bottom
let point = CGPoint(x: actualSelf.contentOffset.x, y: actualSelf.TPKeyboardAvoiding_idealOffsetForView(firstResponder, viewAreaHeight: viewableHeight))
actualSelf.setContentOffset(point, animated: false)
actualSelf.scrollIndicatorInsets = actualSelf.contentInset
actualSelf.layoutIfNeeded()
}
}) { (finished) -> Void in
}
}
@objc func TPKeyboardAvoiding_keyboardWillHide(_ notification:Notification)
{
guard let userInfo = notification.userInfo else { return }
guard let rectNotification = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue else
{
return
}
let keyboardRect = self.convert(rectNotification.cgRectValue , from: nil)
if keyboardRect.isEmpty
{
return
}
let state = self.keyboardAvoidingState()
if !state.keyboardVisible
{
return
}
state.keyboardRect = CGRect.zero
state.keyboardVisible = false
let duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as? Float ?? 0.0
let curve = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? Int ?? 0
let options = UIViewAnimationOptions(rawValue: UInt(curve))
UIView.animate(withDuration: TimeInterval(duration),
delay: 0,
options: options,
animations: { [weak self]() -> Void in
if let actualSelf = self
{
if actualSelf is TPKeyboardAvoidingScrollView {
actualSelf.contentSize = state.priorContentSize
actualSelf.contentInset = state.priorInset
actualSelf.scrollIndicatorInsets = state.priorScrollIndicatorInsets
actualSelf.isPagingEnabled = state.priorPagingEnabled
actualSelf.layoutIfNeeded()
}
}
}) { (finished) -> Void in
}
}
func TPKeyboardAvoiding_updateFromContentSizeChange()
{
let state = self.keyboardAvoidingState()
if state.keyboardVisible
{
state.priorContentSize = self.contentSize
}
}
func TPKeyboardAvoiding_focusNextTextField() ->Bool
{
guard let firstResponder = self.TPKeyboardAvoiding_findFirstResponderBeneathView(self) else { return false}
guard let view = self.TPKeyboardAvoiding_findNextInputViewAfterView(firstResponder, beneathView: self) else { return false}
Timer.scheduledTimer(timeInterval: 0.1, target: view, selector: #selector(becomeFirstResponder), userInfo: nil, repeats: false)
return true
}
func TPKeyboardAvoiding_scrollToActiveTextField()
{
let state = self.keyboardAvoidingState()
if !state.keyboardVisible { return }
let visibleSpace = self.bounds.size.height - self.contentInset.top - self.contentInset.bottom
let idealOffset = CGPoint(x: 0,
y: self.TPKeyboardAvoiding_idealOffsetForView(self.TPKeyboardAvoiding_findFirstResponderBeneathView(self),
viewAreaHeight: visibleSpace))
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double((Int64)(0 * NSEC_PER_SEC)) / Double(NSEC_PER_SEC)) {[weak self] () -> Void in
self?.setContentOffset(idealOffset, animated: true)
}
}
//Helper
func TPKeyboardAvoiding_findFirstResponderBeneathView(_ view:UIView) -> UIView?
{
for childView in view.subviews
{
if childView.responds(to: #selector(getter: isFirstResponder)) && childView.isFirstResponder
{
return childView
}
let result = TPKeyboardAvoiding_findFirstResponderBeneathView(childView)
if result != nil
{
return result
}
}
return nil
}
func TPKeyboardAvoiding_updateContentInset()
{
let state = self.keyboardAvoidingState()
if state.keyboardVisible
{
self.contentInset = self.TPKeyboardAvoiding_contentInsetForKeyboard()
}
}
func TPKeyboardAvoiding_calculatedContentSizeFromSubviewFrames() ->CGSize
{
let wasShowingVerticalScrollIndicator = self.showsVerticalScrollIndicator
let wasShowingHorizontalScrollIndicator = self.showsHorizontalScrollIndicator
self.showsVerticalScrollIndicator = false
self.showsHorizontalScrollIndicator = false
var rect = CGRect.zero
for view in self.subviews
{
rect = rect.union(view.frame)
}
rect.size.height += kCalculatedContentPadding
self.showsVerticalScrollIndicator = wasShowingVerticalScrollIndicator
self.showsHorizontalScrollIndicator = wasShowingHorizontalScrollIndicator
return rect.size
}
func TPKeyboardAvoiding_idealOffsetForView(_ view:UIView?,viewAreaHeight:CGFloat) -> CGFloat
{
let contentSize = self.contentSize
var offset:CGFloat = 0.0
let subviewRect = view != nil ? view!.convert(view!.bounds, to: self) : CGRect.zero
var padding = (viewAreaHeight - subviewRect.height)/2
if padding < kMinimumScrollOffsetPadding
{
padding = kMinimumScrollOffsetPadding
}
offset = subviewRect.origin.y - padding - self.contentInset.top
if offset > (contentSize.height - viewAreaHeight)
{
offset = contentSize.height - viewAreaHeight
}
if offset < -self.contentInset.top
{
offset = -self.contentInset.top
}
return offset
}
func TPKeyboardAvoiding_contentInsetForKeyboard() -> UIEdgeInsets
{
let state = self.keyboardAvoidingState()
var newInset = self.contentInset;
let keyboardRect = state.keyboardRect
newInset.bottom = keyboardRect.size.height - max(keyboardRect.maxY - self.bounds.maxY, 0)
return newInset
}
func TPKeyboardAvoiding_viewIsValidKeyViewCandidate(_ view:UIView)->Bool
{
if view.isHidden || !view.isUserInteractionEnabled {return false}
if view is UITextField
{
if (view as! UITextField).isEnabled {return true}
}
if view is UITextView
{
if (view as! UITextView).isEditable {return true}
}
return false
}
func TPKeyboardAvoiding_findNextInputViewAfterView(_ priorView:UIView,beneathView view:UIView, candidateView bestCandidate: inout UIView?)
{
let priorFrame = self.convert(priorView.frame, to: priorView.superview)
let candidateFrame = bestCandidate == nil ? CGRect.zero : self.convert(bestCandidate!.frame, to: bestCandidate!.superview)
var bestCandidateHeuristic = -sqrt(candidateFrame.origin.x*candidateFrame.origin.x + candidateFrame.origin.y*candidateFrame.origin.y) + ( Float(fabs(candidateFrame.minY - priorFrame.minY))<Float.ulpOfOne ? 1e6 : 0)
for childView in view.subviews
{
if TPKeyboardAvoiding_viewIsValidKeyViewCandidate(childView)
{
let frame = self.convert(childView.frame, to: view)
let heuristic = -sqrt(frame.origin.x*frame.origin.x + frame.origin.y*frame.origin.y)
+ (Float(fabs(frame.minY - priorFrame.minY)) < Float.ulpOfOne ? 1e6 : 0)
if childView != priorView && (Float(fabs(frame.minY - priorFrame.minY)) < Float.ulpOfOne
&& frame.minX > priorFrame.minX
|| frame.minY > priorFrame.minY)
&& (bestCandidate == nil || heuristic > bestCandidateHeuristic)
{
bestCandidate = childView
bestCandidateHeuristic = heuristic
}
}else
{
self.TPKeyboardAvoiding_findNextInputViewAfterView(priorView, beneathView: view, candidateView: &bestCandidate)
}
}
}
func TPKeyboardAvoiding_findNextInputViewAfterView(_ priorView:UIView,beneathView view:UIView) ->UIView?
{
var candidate:UIView?
self.TPKeyboardAvoiding_findNextInputViewAfterView(priorView, beneathView: view, candidateView: &candidate)
return candidate
}
@objc func TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(_ obj: AnyObject)
{
func processWithView(_ view: UIView) {
for childView in view.subviews
{
if childView is UITextField || childView is UITextView
{
self.TPKeyboardAvoiding_initializeView(childView)
}else
{
self.TPKeyboardAvoiding_assignTextDelegateForViewsBeneathView(childView)
}
}
}
if let timer = obj as? Timer, let view = timer.userInfo as? UIView {
processWithView(view)
}
else if let view = obj as? UIView {
processWithView(view)
}
}
func TPKeyboardAvoiding_initializeView(_ view:UIView)
{
if let textField = view as? UITextField,
let delegate = self as? UITextFieldDelegate, textField.returnKeyType == UIReturnKeyType.default &&
textField.delegate !== delegate
{
textField.delegate = delegate
let otherView = self.TPKeyboardAvoiding_findNextInputViewAfterView(view, beneathView: self)
textField.returnKeyType = otherView != nil ? .next : .done
}
}
func keyboardAvoidingState()->TPKeyboardAvoidingState
{
var state = objc_getAssociatedObject(self, &AssociatedKeysKeyboard.DescriptiveName) as? TPKeyboardAvoidingState
if state == nil
{
state = TPKeyboardAvoidingState()
self.state = state
}
return self.state!
}
}
// MARK: - Internal object observer
internal class TPKeyboardAvoidingState:NSObject
{
var priorInset = UIEdgeInsets.zero
var priorScrollIndicatorInsets = UIEdgeInsets.zero
var keyboardVisible = false
var keyboardRect = CGRect.zero
var priorContentSize = CGSize.zero
var priorPagingEnabled = false
}
internal extension UIScrollView
{
fileprivate struct AssociatedKeysKeyboard {
static var DescriptiveName = "KeyBoard_DescriptiveName"
}
var state:TPKeyboardAvoidingState?{
get{
let optionalObject:AnyObject? = objc_getAssociatedObject(self, &AssociatedKeysKeyboard.DescriptiveName) as AnyObject?
if let object:AnyObject = optionalObject {
return object as? TPKeyboardAvoidingState
} else {
return nil
}
}
set{
objc_setAssociatedObject(self, &AssociatedKeysKeyboard.DescriptiveName, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
关于ios - 如何在swift项目中使用TPKeyboardAvoiding?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35625451/
IO 设备如何知道属于它的内存中的值在memory mapped IO 中发生了变化? ? 例如,假设内存地址 0 专用于保存 VGA 设备的背景颜色。当我们更改 memory[0] 中的值时,VGA
我目前正在开发一个使用Facebook sdk登录(通过FBLoginView)的iOS应用。 一切正常,除了那些拥有较旧版本的facebook的人。 当他们按下“使用Facebook登录”按钮时,他
假设我有: this - is an - example - with some - dashesNSRange将使用`rangeOfString:@“-”拾取“-”的第一个实例,但是如果我只想要最后
Card.io SDK提供以下详细信息: 卡号,有效期,月份,年份,CVV和邮政编码。 如何从此SDK获取国家名称。 - (void)userDidProvideCreditCardInfo:(Car
iOS 应用程序如何从网络服务下载图片并在安装过程中将它们安装到用户的 iOS 设备上?可能吗? 最佳答案 您无法控制应用在用户设备上的安装,因此无法在安装过程中下载其他数据。 只需在安装后首次启动应
我曾经开发过一款企业版 iOS 产品,我们公司曾将其出售给大型企业,供他们的员工使用。 该应用程序通过 AppStore 提供,企业用户获得了公司特定的配置文件(包含应用程序配置文件)以启用他们有权使
我正在尝试将 Card.io SDK 集成到我的 iOS 应用程序中。我想为 CardIO ui 做一个简单的本地化,如更改取消按钮标题或“在此保留信用卡”提示文本。 我在 github 上找到了这个
我正在使用 CardIOView 和 CardIOViewDelegate 类,没有可以设置为 YES 的 BOOL 来扫描 collectCardholderName。我可以看到它在 CardIOP
我有一个集成了通话工具包的 voip 应用程序。每次我从我的 voip 应用程序调用时,都会在 native 电话应用程序中创建一个新的最近通话记录。我在 voip 应用程序中也有自定义联系人(电话应
iOS 应用程序如何知道应用程序打开时屏幕上是否已经有键盘?应用程序运行后,它可以接收键盘显示/隐藏通知。但是,如果应用程序在分屏模式下作为辅助应用程序打开,而主应用程序已经显示键盘,则辅助应用程序不
我在模拟器中收到以下错误: ImageIO: CGImageReadSessionGetCachedImageBlockData *** CGImageReadSessionGetCachedIm
如 Apple 文档所示,可以通过 EAAccessory Framework 与经过认证的配件(由 Apple 认证)进行通信。但是我有点困惑,因为一些帖子告诉我它也可以通过 CoreBluetoo
尽管现在的调试器已经很不错了,但有时找出应用程序中正在发生的事情的最好方法仍然是古老的 NSLog。当您连接到计算机时,这样做很容易; Xcode 会帮助弹出日志查看器面板,然后就可以了。当您不在办公
在我的 iOS 应用程序中,我定义了一些兴趣点。其中一些有一个 Kontakt.io 信标的名称,它绑定(bind)到一个特定的 PoI(我的意思是通常贴在信标标签上的名称)。现在我想在附近发现信标,
我正在为警报提示创建一个 trigger.io 插件。尝试从警报提示返回数据。这是我的代码: // Prompt + (void)show_prompt:(ForgeTask*)task{
您好,我是 Apple iOS 的新手。我阅读并搜索了很多关于推送通知的文章,但我没有发现任何关于 APNS 从 io4 到 ios 6 的新更新的信息。任何人都可以向我提供 APNS 如何在 ios
UITabBar 的高度似乎在 iOS 7 和 8/9/10/11 之间发生了变化。我发布这个问题是为了让其他人轻松找到答案。 那么:在 iPhone 和 iPad 上的 iOS 8/9/10/11
我想我可以针对不同的 iOS 版本使用不同的 Storyboard。 由于 UI 的差异,我将创建下一个 Storyboard: Main_iPhone.storyboard Main_iPad.st
我正在写一些东西,我将使用设备的 iTunes 库中的一部分音轨来覆盖 2 个视频的组合,例如: AVMutableComposition* mixComposition = [[AVMutableC
我创建了一个简单的 iOS 程序,可以顺利编译并在 iPad 模拟器上运行良好。当我告诉 XCode 4 使用我连接的 iPad 设备时,无法编译相同的程序。问题似乎是当我尝试使用附加的 iPad 时
我是一名优秀的程序员,十分优秀!