如何在iPhone上制作弹出窗口?

时间:2011-04-23 18:52:14

标签: iphone objective-c

我知道之前曾问过这种问题,但我不能为我的生活找到它。我需要创建一个弹出窗口(蓝色窗口之一,就像在应用程序商店中输入密码一样)。所以,我有三个简单的(希望)问题。

  • 什么是弹出窗口?

  • 如何制作只有可滚动文字和按钮的文件?

  • 如何确定按下按钮的时间,并对其执行某些操作?

注意:我只问了三个问题,因为我觉得它们很容易回答。事实上,我认为第一个问题可以在用于显示弹出窗口的代码中得到解答。第三个问题需要回答才能使用此功能。

此外,这不是“给我看看代码”问题。我只想指出谈论这些问题的文档,尽管直接答案非常有用。

2 个答案:

答案 0 :(得分:8)

What is the popup window called?

UIAlertView中

  

如何制作只有可滚动文字和按钮的文件?

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Some Title" message:@"\n\n\n\n" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];

UITextView *someTextView = [[UITextView alloc] initWithFrame:CGRectMake(15, 35, 250, 100)];
someTextView.backgroundColor = [UIColor clearColor];
someTextView.textColor = [UIColor whiteColor];
someTextView.editable = NO;
someTextView.font = [UIFont systemFontOfSize:15];
someTextView.text = @"Enter Text Here";
[alert addSubview:someTextView];
[alert show];
[someTextView release];
[alert release];
  

如何确定何时按下按钮并对其执行某些操作?

如前所述UIAlertViewDelegate

答案 1 :(得分:2)

  

什么是弹出窗口?

UIAlertView

  

如何制作只有可滚动文字和按钮的文件?

不直接在警报视图中滚动文本。您可以尝试将自定义UITextView作为子视图添加到警报视图以实现此效果。

  

如何确定何时按下按钮并对其执行某些操作?

通过实施UIAlertViewDelegate的适当委托方法。