gpt4 book ai didi

ios - 使用 Storyboard中的 View 将 XIB 中 UIView 的 UITextField 加载到 ViewCrontroller

转载 作者:行者123 更新时间:2023-11-28 06:54:47 24 4
gpt4 key购买 nike

我不断收到 setValue:forUndefinedKey:]:此类对于键 dummyTextField 不符合键值编码。'

编辑: 我需要将 UIView(nib 文件)中的 UITextField 连接到 ViewController。 UIView 作为 ViewController 中的 subview 加载。按下按钮后我想要 UITextField 的内容

请下载以下文件并试用。如果你能帮我解决这个问题,我将不胜感激。

https://drive.google.com/file/d/0B_Z-8IMBX2LcSURBRktzZ2tzWWc/view?usp=sharing

请注意,我已成功让按钮在该 Controller 中工作,错误仅出在文本字段的 IBOutlet 上。

如果您能想出另一种方法来完成此任务(例如使用委托(delegate)方法),我会洗耳恭听。

谢谢

附言我用谷歌搜索了一下,发现很多人都有类似的问题,但它并没有解决我的问题。

最佳答案

为此,您需要先设置 Root View Controller 。

var window: UIWindow?
var navController:UINavigationController?
var viewController:ViewController?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
// Override point for customization after application launch.

window = UIWindow(frame: UIScreen.mainScreen().bounds)
viewController = ViewController(nibName: "subview", bundle: nil);
navController = UINavigationController(rootViewController: viewController!);
navController?.navigationBarHidden = true
window?.rootViewController = navController;
window?.makeKeyAndVisible()
return true
}

之后点击你的项目

You can see now PROJECT and TARGET
Click your project of TARGETS
Click General.
Now you can see the Deployment Info
Delete the Main from Dropbox of Main Interface

现在去 subview XIB

Click Files's Owner of Placeholder'e.
Then click Identity Inspector of Utility Area which is in right side.
Click Class of CustomClass
Then choose ViewController from Dropdown box of class and click Enter.
And go to Connection's Inspector of Utility Area which is in right side.
Now See the Outlets.Under Outlets, there is View.Now You have drag(Contorl+ drag the Empty Circle to Xib View) the view empty circle to the Xib View.Now empty circle is filled with black or gray color.
Finally connect the textField and Button to Outlet.

现在它完美地工作了-:)

关于ios - 使用 Storyboard中的 View 将 XIB 中 UIView 的 UITextField 加载到 ViewCrontroller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33965973/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com