2011年6月21日火曜日

UIAlertViewを使って値を入力する方法

// Create Alert 
UIAlertView* av = [UIAlertView new]; 
av.delegate = self;
av.title = @"New Folder"
// Add Buttons 
[av addButtonWithTitle:@"OK"]; 
[av addButtonWithTitle:@"Cancel"]; 
// Make Space for Text View 
av.message = @"\n"
// Adjust the frame 
CGRect frame = av.frame
frame.origin.y -= -100.0f; 
av.frame = frame; 


// ここで UITextFieldを追加してやる

UITextField* text 
= [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)]; 
text.borderStyle = UITextBorderStyleRoundedRect
[av addSubview:text]; 
[text becomeFirstResponder]; 

[av show]; 
NSLog(@"text->%@",text.text);
[text release];
[av release];

0 件のコメント: