我想知道是否有任何方法可以检查更好的预测文本(键盘上方的灰色框)是否已启用.
当文本字段获得焦点时,我需要这样可以将视图中的几个像素加到顶部.我得到了键盘的大小:CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
我想在导航栏的中间放置一个比导航栏本身大的图像。到目前为止,我尝试将 UIView 与 UIImageView 一起使用,并且效果很好,正如您在此处看到的:
但是,只要我推另一个控制器并弹出我的 ImageView 就会再次裁剪为 NavigationBar 的大小。
到目前为止,我的 iOS 11 代码:
override func viewDidLoad() {
super.viewDidLoad()
let logo = UIImage(named: "Logo")
let titleView = UIView(frame: CGRect(x: 0, y: 0, width: 60, height: 60))
let imageView = UIImageView(image: logo)
imageView.frame = CGRect(x: 0, y: 0, width: titleView.frame.width, height: titleView.frame.height)
titleView.addSubview(imageView)
imageView.contentMode = .scaleAspectFit
imageView.image = logo
navigationItem.titleView = titleView
}
Run Code Online (Sandbox Code Playgroud)
编辑:目前有一个临时解决方案,它使用观察者覆盖导致问题的视图的 clipsToBounds 属性:链接(为此向@trungduc 大喊)
有人可以告诉我如何在KIF 2.0的uiwebview中访问输入字段吗?不幸的是,我在KIF Framework Github上找不到任何东西,无论是在文档中还是在示例中.我试图通过它的id访问输入字段,但这似乎不起作用:
[tester tapViewWithAccessibilityLabel:@"username"];.
提前致谢.如果您有关于KIF 2.0的一些不错的资源,如果您将它们发送给我,我会很高兴.
我有一个存储枚举的类,并提供一个函数,如果枚举作为参数给出,则将此枚举显示为字符串.
enum ErrorType: String {
case InvalidInputTextFieldEmpty = "One or more inputs seem empty. Please enter your credentials."
case InvalidInputPasswordsNotMatch = "Please check your passwords they doesn't seem to match."
}
class ErrorManager: NSObject {
func handleError(errorType: ErrorType)
{
self.showAlertView(errorType.rawValue)
}
func showAlertView(message:String)
{
var alertView:UIAlertView = UIAlertView(title: "Notice", message: message, delegate: self, cancelButtonTitle: "OK")
alertView.show()
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想在另一个类中访问函数handleError:
ErrorManager.handleError(ErrorType.InvalidInputTextFieldEmpty)
但编译抱怨参数是n0t,如果有类型ErrorManager虽然我写的参数是类型ErrorType.我在这做错了什么?