在 Objective C 中为 iOS 创建模式窗口

发布于 2024-11-16 11:10:05 字数 142 浏览 0 评论 0原文

我必须为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梦断已成空 2024-11-23 11:10:05

一种灵活的方法是让调用代码传入父视图控制器。像这样的东西会起作用:

[CustomLoginManagerClass shownLoginOver:self.viewController otherStuff:_____];

然后假设你的方法定义是这样的,你可以轻松地从那里启动你的模式。

+ (void)shownLoginOver:(UIViewController*)viewController otherStuff:(id)stuff
{
  [self presentModalViewController:viewController animated:YES];
}

请注意,我在示例中为此使用了类方法。这更简洁,因为您要求它做的只是从现有视图控制器启动模式。此结构在 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:

[CustomLoginManagerClass shownLoginOver:self.viewController otherStuff:_____];

and then assuming your method definition is something like this, you can easily launch your modal from there.

+ (void)shownLoginOver:(UIViewController*)viewController otherStuff:(id)stuff
{
  [self presentModalViewController:viewController animated:YES];
}

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.

浊酒尽余欢 2024-11-23 11:10:05

您需要一个模式视图。所有 UIViewControllers 都能够使用以下方法呈现模态视图:

[self presentModalViewController:yourViewController animated:YES];

查看 Apple 参考指南以获取更多信息和示例。

You want a modal view. All UIViewControllers are able to present a modal view by using the following method:

[self presentModalViewController:yourViewController animated:YES];

Check the Apple reference guides for more information and samples.

烟沫凡尘 2024-11-23 11:10:05

呈现它:

  // to change the style of presentation
 viewController.modalPresentationStyle = UIModalPresentationStyle//....;
 //to change the transition
 viewController.modalTransitionStyle = UIModalTransitionStyle//...;
[self presentModalViewController:viewController animated:YES];

present it with:

  // to change the style of presentation
 viewController.modalPresentationStyle = UIModalPresentationStyle//....;
 //to change the transition
 viewController.modalTransitionStyle = UIModalTransitionStyle//...;
[self presentModalViewController:viewController animated:YES];
无人问我粥可暖 2024-11-23 11:10:05

您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文