在 Objective C 中为 iOS 创建模式窗口
我必须为 iphone 创建一个静态库,它提供了一个登录界面。登录提示一个窗口并询问用户名和密码。
我想创建一个模式窗口。由于接口不接受任何参数。我必须创建一个独立的窗口,并在其上放置文本框和登录按钮。 请建议我这样做的方法。
谢谢...
I have to create a static library for iphone which provides a interface Login. Login prompts a window and asks username and password.
I wanted to create a modal window. As the interface doesnt take any arguments. I have to create a independent window and put text boxes and login button on it.
Plz suggest me way to do this.
Thanks...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
一种灵活的方法是让调用代码传入父视图控制器。像这样的东西会起作用:
然后假设你的方法定义是这样的,你可以轻松地从那里启动你的模式。
请注意,我在示例中为此使用了类方法。这更简洁,因为您要求它做的只是从现有视图控制器启动模式。此结构在 DSActivityView 中使用效果良好(请参阅:http://www.dejal.com/blog/development )。这是一个用于在任何其他视图之上显示模式加载屏幕的库。
或者,您可能希望根据您的需要将其设为实例方法。
A flexible way to do this is to make the calling code pass in the parent view controller. Something like this would work:
and then assuming your method definition is something like this, you can easily launch your modal from there.
Note that I have used a class method for this in my example. This is neater since all you are asking it to do is launch a modal from an existing view controller. This structure is used to good effect in DSActivityView (see: http://www.dejal.com/blog/development). This is a library for displaying modal loading screens over the top any other view.
Alternatively you may want to make it an instance method depending on your needs.
您需要一个模式视图。所有
UIViewControllers
都能够使用以下方法呈现模态视图:查看 Apple 参考指南以获取更多信息和示例。
You want a modal view. All
UIViewControllers
are able to present a modal view by using the following method:Check the Apple reference guides for more information and samples.
呈现它:
present it with:
您可以使用
NSRunLoop
创建一个“模态窗口”来玩游戏,但我不推荐这样做。这很容易出错,而且不是“Cocoa 方式”。我建议您以通常的方式实现它,非模态地使用委托或块来通知结果。
You can create a "modal window" playing games with the
NSRunLoop
, but I don't recommend it. It's very error prone and it's not the "Cocoa way".I suggest you implement it the usual way, non modal with a delegate or block to inform the result.