Created
February 25, 2014 05:21
-
-
Save keicoder/9203199 to your computer and use it in GitHub Desktop.
oobjective-c : UIAlertView 텍스트 입력 받기
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//UIAlertView 텍스트 입력 받기 | |
//TWAlbumTableViewController.h | |
@interface TWAlbumTableViewController : UITableViewController | |
@property (strong, nonatomic) NSMutableArray *albums; | |
- (IBAction)addAlbumBarButtonPressed:(UIBarButtonItem *)sender; | |
@end | |
//TWAlbumTableViewController.m | |
@interface TWAlbumTableViewController () <UIAlertViewDelegate> //alertView 델리게이트 | |
- (IBAction)addAlbumBarButtonPressed:(UIBarButtonItem *)sender | |
{ | |
UIAlertView *newAlbumAlertView = [[UIAlertView alloc] initWithTitle:@"Enter New Album Name" | |
message:nil | |
delegate:self | |
cancelButtonTitle:@"Cancel" | |
otherButtonTitles:@"Add", nil]; | |
[newAlbumAlertView setAlertViewStyle:UIAlertViewStylePlainTextInput]; //alertView 스타일 지정 | |
[newAlbumAlertView show]; | |
} | |
#pragma mark - UIAlertView 델리게이트 | |
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex | |
{ | |
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));} | |
if (buttonIndex == 1) { | |
//textFieldAtIndex:0 - alertView 스타일을 UIAlertViewStylePlainTextInput으로 지정 했음 | |
NSString *alertText = [alertView textFieldAtIndex:0].text; | |
NSLog (@"My new album is %@", alertText); | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment