我正在尝试为用户创建登录名以输入用户名和密码。我正在使用Xcode 4.5。这是我的.h文件代码:
#import <UIKit/UIKit.h>
#import "AccountViewController.m"
@interface AccountViewController : UIViewController {
}
- (IBAction) alert: (id)sender;
@end
这是我的.m文件代码:
#import "AccountViewController.h"
@implementation AccountViewController
- (IBAction)alert:(id)sender
{
UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"Log In" message:@"Please enter your Username and Password" delegate:self cancelButtonTitle:@"Log In" otherButtonTitles:@"Cancel", nil];
[alert addTextFieldWithValue:@"" label:@"Username"];
[alert addTextFieldWithValue:@"" label:@"Password"];
UITextField *tf = [alert textFieldAtIndex:0];
tf.clearButtonMode = UITextFieldViewModeWhileEditing;
tf.keyboardType = UIKeyboardTypeAlphabet;
tf.keyboardAppearance = UIKeyboardAppearanceAlert;
tf.autocapitalizationType = UITextAutocapitalizationTypeWords;
tf.autocorrectionType = UITextAutocorrectionTypeNo;
tf = [alert textFieldAtIndex:1];
tf.clearButtonMode = UITextFieldViewModeWhileEditing;
tf.keyboardType = UIKeyboardTypeURL;
tf.keyboardAppearance = UIKeyboardAppearanceAlert;
tf.autocapitalizationType = UITextAutocapitalizationTypeWords;
tf.autocorrectionType = UITextAutocorrectionTypeNo;
[alert show];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
}
@end
此处的错误发生在.m文件中,用于以下每行代码:
[alert addTextFieldWithValue:@"" label:@"Username"];
[alert addTextFieldWithValue:@"" label:@"Password"];
错误是:'UIAlertView'没有可见的@interface声明选择器'addTextFieldWithValue:label:'
任何帮助都将不胜感激。
谢谢!
答案 0 :(得分:0)
addTextFieldWithValue
在这做什么? UIAlertView
下没有列出此类方法。
此外,如果您要处理提醒按钮上的点击事件,请在您的课程中加入UIAlertViewDelegate
。