首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iphone代码示例

iphone代码示例
EN

Stack Overflow用户
提问于 2011-02-07 11:46:10
回答 1查看 228关注 0票数 0

我想要显示登录窗口,然后键入登录和密码密码,它将打开帐户。所以我尝试了,但是它显示了错误,比如/81: error:'didReceiveMemoryWarning‘未声明(在这个函数中第一次使用) *:81: error:100之前的'{’令牌* 100:错误:在输入末尾的预期声明或语句

我在下面贴了代码,请帮忙,谢谢。

.h文件

代码语言:javascript
复制
#import <UIKit/UIKit.h>

@interface Password1ViewController : UIViewController {

UITextField *textfieldName;
UITextField *textfieldPassword;

}
@property (nonatomic, retain) IBOutlet UITextField *textfieldName;
@property (nonatomic, retain) IBOutlet UITextField *textfieldPassword;

@end

.m文件

代码语言:javascript
复制
#import "Password1ViewController.h"

@implementation Password1ViewController

@synthesize textfieldName;
@synthesize textfieldPassword;

-(void)alertView:(UIAlertView *)alertview clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex != [alertview cancelButtonIndex])
    {

        NSLog(@"Name: %@", textfieldName.text);
        NSlog(@"Name: %@", textfieldPassword.text);
    }
}

-(void) someMethod
{
    UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"Please Login" message:@""                                            delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Submit",nil];

    [alert addTextFieldWithValue:@"" label:@"User Name"];
    [alert addTextFieldWithValue:@"" label:@"Password"];

    textfieldName = [alert textFieldAtIndex:0];
    textfieldName.keyboardType = UIKeyboardTypeAlphabet;
    textfieldName.keyboardAppearance = UIKeyboardAppearanceAlert;
    textfieldName.autocorrectionType = UITextAutocorrectionTypeNo;

    textfieldPassword = [alert textFieldAtIndex:1];
    textfieldPassword.clearButtonMode = UITextFieldViewModeWhileEditing;
    textfieldPassword.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
    textfieldPassword.keyboardAppearance = UIKeyboardAppearanceAlert;
    textfieldPassword.autocorrectionType = UITextAutocorrectionTypeNo;
    textfieldPassword.secureTextEntry = YES;

    [alert show];
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)dealloc {
    [textfieldName release];
    [textfieldPassword release];
    [super dealloc];
}

@end
EN

回答 1

Stack Overflow用户

发布于 2011-02-07 12:11:10

你错过了一个结束支撑,我在我的编辑中修正了。所以,现在尝试使用已编辑的代码。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4920939

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档