zoukankan      html  css  js  c++  java
  • 2013.8.12 作业

    创建登陆窗口(有用户名和密码),确认后弹出对话框再输入一遍,如果都相同,显示用户图片,如果不相同,弹出上拉菜单(UIActionSheet)_,问是否重新输入,是的话弹出对话框重新输入。

    //
    //  AppDelegate.h
    //  UI1
    //
    //  Created by The9 on 13-8-13.
    //  Copyright (c) 2013年 jk. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @class ViewController;
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    
    @property (strong, nonatomic) UIWindow *window;
    
    @property (strong, nonatomic) ViewController *viewController;
    
    @end
    

      

    //
    //  AppDelegate.m
    //  UI1
    //
    //  Created by The9 on 13-8-13.
    //  Copyright (c) 2013年 jk. All rights reserved.
    //
    
    #import "AppDelegate.h"
    
    #import "ViewController.h"
    
    @implementation AppDelegate
    
    - (void)dealloc
    {
        [_window release];
        [_viewController release];
        [super dealloc];
    }
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        // Override point for customization after application launch.
        self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
        self.window.rootViewController = self.viewController;
        [self.window makeKeyAndVisible];
        return YES;
    }
    
    - (void)applicationWillResignActive:(UIApplication *)application
    {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }
    
    - (void)applicationDidEnterBackground:(UIApplication *)application
    {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }
    
    - (void)applicationWillEnterForeground:(UIApplication *)application
    {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }
    
    - (void)applicationDidBecomeActive:(UIApplication *)application
    {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }
    
    - (void)applicationWillTerminate:(UIApplication *)application
    {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }
    
    @end
    

      

    //
    //  ViewController.h
    //  UI1
    //
    //  Created by The9 on 13-8-13.
    //  Copyright (c) 2013年 jk. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    #import "MyDelegate.h"
    
    
    NSString *s1;
    NSString *s2;
    
    UIImageView *view2;
    UIImageView *view1;
    
    UIAlertView *alert;
    
    @interface ViewController : UIViewController<UITextViewDelegate>
    @property (retain, nonatomic) IBOutlet UITextField *account;
    @property (retain, nonatomic) IBOutlet UITextField *password;
    @property (retain, nonatomic) IBOutlet UIButton *enter;
    @property (retain, nonatomic) IBOutlet UIImageView *catView;
    
    
    - (IBAction)accountClick:(id)sender;
    
    - (IBAction)passClick:(id)sender;
    
    
    - (IBAction)enterClick:(id)sender;
    
    - (IBAction)viewClick:(id)sender;
    
    @end
    

      

    //
    //  ViewController.m
    //  UI1
    //
    //  Created by The9 on 13-8-13.
    //  Copyright (c) 2013年 jk. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @interface ViewController ()
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad
    {
        view1=self.view;
        view2=self.catView;
        [super viewDidLoad];
        [self.account becomeFirstResponder];
    	// Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    - (void)dealloc {
        [_account release];
        [_password release];
        [_enter release];
    
        [_catView release];
        [super dealloc];
    }
    - (IBAction)accountClick:(id)sender {
       }
    
    - (IBAction)passClick:(id)sender {
       
    }
    
    - (IBAction)enterClick:(id)sender {
        
        NSLog(@"%@",self.account.text);
        NSLog(@"%@",self.password.text);
        s1=self.account.text;
        s2=self.password.text;
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"确认密码" message:@"请再次输入"delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
        [alert show];
    }
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        switch (buttonIndex) {
            case 0:
                //取消
                NSLog(@"quxiao");
                break;
            case 1:
                //确定
            {
                MyDelegate *mydelegate=[[MyDelegate alloc]init];
                alert=[[UIAlertView alloc]initWithTitle:@"确认密码" message:@"请再次输入"delegate:mydelegate cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
                alert.alertViewStyle=UIAlertViewStyleLoginAndPasswordInput;
                [alert show];
                           
            }
                break;
            default:
                break;
        }
    }
    
    
    - (IBAction)viewClick:(id)sender {
        [self.account resignFirstResponder];
         [self.password resignFirstResponder];
    
    }
    
    
    @end
    

      

    //
    //  MyDelegate.h
    //  UI1
    //
    //  Created by The9 on 13-8-13.
    //  Copyright (c) 2013年 jk. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    #import "ViewController.h"
    
    @interface MyDelegate : NSObject <UIAlertViewDelegate,UIActionSheetDelegate>
    
    @end
    

      

    //
    //  MyDelegate.m
    //  UI1
    //
    //  Created by The9 on 13-8-13.
    //  Copyright (c) 2013年 jk. All rights reserved.
    //
    
    #import "MyDelegate.h"
    
    @implementation MyDelegate
    
    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        switch (buttonIndex) {
            case 0:
                //取消
                NSLog(@"quxiao");
                break;
            case 1:
                //确定
            {
                NSString *s3=[alertView textFieldAtIndex:0].text;
                NSString *s4=[alertView textFieldAtIndex:1].text;
                if ([s1 isEqualToString:s3]&&[s2 isEqualToString:s4]) {
            
                    view2.hidden=NO;
                  
                }
              else
              {
                  UIActionSheet *actionsheet=[[UIActionSheet alloc]initWithTitle:@"输入错误" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"重试" otherButtonTitles:nil];
                  [actionsheet showInView:view1];
                  
              }
               
            }
                
        
                break;
            default:
                break;
        }
    }
    
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        switch (buttonIndex) {
            case 0:
                //取消
                
                NSLog(@"chongshi");
                [alert show];
                break;
            case 1:
                break;
            default:
                break;
        }
    
    }
    @end
    

      

     

  • 相关阅读:
    Linux内核设计第三周学习总结 跟踪分析Linux内核的启动过程
    Linux内核设计第二周学习总结 完成一个简单的时间片轮转多道程序内核代码
    Linux内核设计第一周学习总结 计算机如何工作
    信息安全系统设计基础期末总结
    信息安全系统设计基础第十四周学习总结
    信息安全系统设计基础第十三周学习总结
    20135310陈巧然 20135305姚歌 实验四:外设驱动程序设计
    linux内核设计与实现一书阅读整理 之第一二章整合
    20135239 益西拉姆 linux内核分析 使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用
    20135239 益西拉姆 linux内核分析 跟踪分析Linux内核的启动过程
  • 原文地址:https://www.cnblogs.com/ymonke/p/3254467.html
Copyright © 2011-2022 走看看