//在APPDelegate.h中,即項目的入口部分
在嵐縣等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè) 網(wǎng)站設(shè)計制作按需定制開發(fā),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),成都全網(wǎng)營銷推廣,外貿(mào)網(wǎng)站制作,嵐縣網(wǎng)站建設(shè)費用合理。//didFinishLaunchingWithOptions該方法表示APP啟動完畢,接下來進(jìn)入自定義界面
//如下MyViewController是自定義的類,即一個界面實現(xiàn)UIViewController接口
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; MyViewController *myController = [[MyViewController alloc] init]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myController]; self.window.rootViewController = navController; [self.window makeKeyAndVisible]; return YES; }
//MyViewController.h //定義四個控件 @interface MyViewController : UIViewController @property (strong, nonatomic) UILabel *labelNum; @property (strong, nonatomic) UILabel *labelPwd; @property (strong, nonatomic) UITextField *fieldNum; @property (strong, nonatomic) UITextField *fieldPwd; @end //MyViewController.m - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.labelNum = [[UILabel alloc] init]; self.labelNum.frame = CGRectMake(100, 100, 50, 20); self.labelNum.text = @"Num: "; self.fieldNum = [[UITextField alloc] init]; self.fieldNum.frame = CGRectMake(150, 100, 100, 20); self.fieldNum.borderStyle = UITextBorderStyleRoundedRect; self.labelPwd = [[UILabel alloc] init]; self.labelPwd.frame = CGRectMake(100, 150, 50, 20); self.labelPwd.text = @"Pwd: "; self.fieldPwd = [[UITextField alloc] init]; self.fieldPwd.frame = CGRectMake(150, 150, 100, 20); self.fieldPwd.borderStyle = UITextBorderStyleRoundedRect; UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(100, 200, 80, 20); btn.backgroundColor = [UIColor grayColor]; [btn setTitle:@"login" forState:UIControlStateNormal]; //設(shè)置按鈕監(jiān)聽事件,監(jiān)聽方法為login [btn addTarget:self action:@selector(login) forControlEvents:UIControlEventTouchDown]; [self.view addSubview:self.labelNum]; [self.view addSubview:self.fieldNum]; [self.view addSubview:self.labelPwd]; [self.view addSubview:self.fieldPwd]; [self.view addSubview:btn]; }
//頁面跳轉(zhuǎn),并傳遞參數(shù)
-(void) login{ NSLog(@"login"); NSString *num = self.fieldNum.text; NSString *pwd = self.fieldPwd.text; if([num isEqualToString:@"123"] == TRUE){ NSLog(@"yes"); //初始化要跳轉(zhuǎn)的界面 MainViewController *mm = [[MainViewController alloc] init]; //把賬號密碼傳遞到下個界面 [mm initData:num two:pwd]; //開始跳轉(zhuǎn) [self.navigationController pushViewController:mm animated:FALSE]; }else{ NSLog(@"error"); } }
//MainViewController.h
@interface MainViewController : UIViewController //@property( nonatomic) NSString //傳遞兩個參數(shù)a、b NSString 類型 -(void) initData:(NSString *) a two:(NSString *) b; @end
//接收參數(shù),并保存 -(void) initData:(NSString *) a two:(NSString *) b{ self.num = a; self.pwd = b; NSLog(@"%@,%@", self.num, self.pwd); }
//效果圖
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
網(wǎng)站標(biāo)題:界面的跳轉(zhuǎn)和傳值-創(chuàng)新互聯(lián)
標(biāo)題來源:http://aaarwkj.com/article12/jccdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、網(wǎng)站內(nèi)鏈、面包屑導(dǎo)航、外貿(mào)建站、微信小程序、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容