Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone Alertview上的警告_Iphone_Objective C - Fatal编程技术网

Iphone Alertview上的警告

Iphone Alertview上的警告,iphone,objective-c,Iphone,Objective C,可能重复: 我使用下面的代码在AlertView中放置textfield,它会发出类似UIAlertView可能不响应-addTextFieldWithValue:label:&UIAlertView可能不响应-textFieldAtIndex UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email" message:@""

可能重复:

我使用下面的代码在AlertView中放置textfield,它会发出类似UIAlertView可能不响应-addTextFieldWithValue:label:&UIAlertView可能不响应-textFieldAtIndex

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email" message:@""
                                                   delegate:self cancelButtonTitle:@"Cancel"  otherButtonTitles:@"Submit", nil];

[alert addTextFieldWithValue:@"" label:@"Email"];
// Username
textfieldName = [alert textFieldAtIndex:0];
textfieldName.keyboardType = UIKeyboardTypeEmailAddress;
textfieldName.keyboardAppearance = UIKeyboardAppearanceAlert;
textfieldName.autocorrectionType = UITextAutocorrectionTypeNo;
[alert show];

请帮忙

UIAlertView中没有像addTextFieldWithValue这样的方法。

UIAlertView中没有addTextFieldWithValue这样的方法

如果您需要修改警报视图,请查看我的博客-

[alert addTextFieldWithValue:@label:@Email];是一个私有api。我的应用因为使用此而被拒绝

用这个

UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"Twitter" 
                                                          message:@"\n\n\n\n"  
                                                         delegate:self 
                                                cancelButtonTitle:@"" 
                                                otherButtonTitles:@"", nil];


myAlert.frame = CGRectMake( 0, 0, 300, 260);
textfieldName = [[UITextField alloc] initWithFrame:CGRectMake(13, 95, 260, 25.0)];
[textfieldName setBackgroundColor:[UIColor whiteColor]];
textfieldName.placeholder = @"xyz";
textfieldName.keyboardType = UIKeyboardTypeAlphabet;
textfieldName.keyboardAppearance = UIKeyboardAppearanceAlert;
textfieldName.autocorrectionType = UITextAutocorrectionTypeNo;
textfieldName.delegate = self;
textfieldName.tag = 1;
[myAlert addSubview:textfieldName];

你想说什么?
**I use in my project < and use and implement
use in .h file**

@protocol InputAlertViewDelegate
 -(void)handleEnteredValue:(NSString*)_value; 
-(void)handleCancellation; 
@end
@interface InputAlertView : UIAlertView <UIAlertViewDelegate> { 
UITextField *textField;

id<InputAlertViewDelegate> caller;

} @property(nonatomic, retain) UITextField *textField; 
@property(nonatomic, retain) id<InputAlertViewDelegate> caller; 
-(NSString*) theText;
 -(void) prepare; 
-(void) makePassword;
 -(void) makeTelephone; 
+(InputAlertView*) inputAlertViewWithTitle:(NSString*)_title initialFieldText:(NSString*)_text caller:(id<InputAlertViewDelegate>)_caller;


**use in .m file**


+(InputAlertView*) inputAlertViewWithTitle:(NSString*)_title initialFieldText:(NSString*)_text

caller:(id<InputAlertViewDelegate>)_caller
{ 
InputAlertView  *_alert =
[[[self alloc] initWithTitle:_title message:@"\n" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil] autorelease];
_alert.delegate = _alert;
 _alert.caller = _caller; 
[_alert prepare];
 _alert.textField.text = _text; 
return _alert;
}


-(void)prepare
{ 
self.textField = [[[UITextField alloc] initWithFrame:CGRectMake(12.0, 45, 260.0, 30.0)] autorelease];

[textField setBackgroundColor:[UIColor clearColor]]; 
textField.borderStyle = UITextBorderStyleRoundedRect; 
textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
 [self addSubview:textField];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0.0, 130.0);
[self setTransform:myTransform];

-(void) show{ 
[textField becomeFirstResponder]; 
[super show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if(buttonIndex == 1){ [self.caller handleCancellation];
} else{
[self.caller handleEnteredValue:[self theText]];
}
}