我尝试下面的代码: UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle
![](http://bbs.51cto.com/images/smilies/default/huffy.gif)
destructiveButtonTitle:nil
otherButtonTitles:nil];
UITextField *pickerView_freq_payment = [[UITextField alloc] init];
[menu addSubview:pickerView_freq_payment];
[menu showInView:self.view];
[menu sendSubviewToBack:pickerView_freq_payment];
[menu setBounds:CGRectMake(0,0,320, 300)];
CGRect pickerRect = pickerView_freq_payment.bounds;
pickerView_freq_payment.bounds = pickerRect;
[pickerView_freq_payment release];
[menu release];
复制代码但是没办法在文本框中显示。
我在action sheet中显示按钮,但是需要在按钮处放置文本框。
应该如何做呢?
哪位大神有什么想法?
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
你不需要这么做。
参看下面的代码: - (void)alertViewUIAlertView *)alertView clickedButtonAtIndex
NSInteger)buttonIndex
{
// Clicked the Submit button
if (buttonIndex != [alertView cancelButtonIndex])
{
NSLog(@"Name: %@", textfieldName.text);
NSLog(@"Name: %@", textfieldPassword.text);
}
}
...
- (void) someMethod
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle"
lease Login" message
""
delegate:self cancelButtonTitle"Cancel" otherButtonTitles
"Submit", nil];
[alert addTextFieldWithValue"" label
"User Name"];
[alert addTextFieldWithValue"" label
"
assword"];
// Username
textfieldName = [alert textFieldAtIndex:0];
textfieldName.keyboardType = UIKeyboardTypeAlphabet;
textfieldName.keyboardAppearance = UIKeyboardAppearanceAlert;
textfieldName.autocorrectionType = UITextAutocorrectionTypeNo;
// Password
textfieldPassword = [alert textFieldAtIndex:1];
textfieldPassword.clearButtonMode = UITextFieldViewModeWhileEditing;
textfieldPassword.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
textfieldPassword.keyboardAppearance = UIKeyboardAppearanceAlert;
textfieldPassword.autocorrectionType = UITextAutocorrectionTypeNo;
textfieldPassword.secureTextEntry = YES;
[alert show];
}