简体   繁体   中英

How to make a popup window on iphone?

I know this kind of question was asked before, but I cannot for the life of me find it. I need to make a popup window (one of the blue ones, like in the app store for typing the password). So, I have three simple (hopefully) questions.

  • What is the popup window called?

  • How do I make one with only scrollable text and a button?

  • How can I figure out when the button was pressed, and do something with it?

NOTE: I am only asking three questions because I think they can be answered very easily. Infact, I think the first question can be answered just in the code used to make it show the popup window. The third question needs to be answered just to use this feature.

Also, this is not a "show me teh codez" question. I only want to be pointed to the documentation that talks about these, although direct answers would be very useful.

What is the popup window called?

UIAlertView

How do I make one with only scrollable text and a button?

    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];

How can I figure out when the button was pressed, and do something with it?

As stated before UIAlertViewDelegate

What is the popup window called?

UIAlertView

How do I make one with only scrollable text and a button?

Scrolling text inside the alert view is not supported directly. You can try to add a custom UITextView as a subview to the alert view to achieve that effect.

How can I figure out when the button was pressed, and do something with it?

By implementing the appropriate delegate method of UIAlertViewDelegate .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM