作為IOS開(kāi)發(fā)人員,在進(jìn)行開(kāi)發(fā)之前,你肯定會(huì )和客戶(hù)溝通,客戶(hù)到底需要的是什么樣的app?你要怎么去開(kāi)發(fā)。雖然你可以讓客戶(hù)給你個(gè)例子,如客戶(hù)覺(jué)得哪一款app的界面、功能比較好,會(huì )告訴你參考,但是最為開(kāi)發(fā)人員,還是要考慮很多因素。下面app軟件開(kāi)發(fā)小編以一個(gè)在威客網(wǎng)上看到的一個(gè)開(kāi)發(fā)任務(wù)為例,進(jìn)行解析:
任務(wù)的內容:手機android端和IOS開(kāi)發(fā),PC端基于B/S架構應用。首先明白技術(shù)上的要求:
首先,客戶(hù)提出B/S架構主要是區別于C/S結構。這個(gè)不用客戶(hù)說(shuō),PC端肯定是基于B/S架構的,現在的pc上在廣域網(wǎng)上運行的,且B/S架構可以服務(wù)器操作系統的選擇較多,滿(mǎn)足客戶(hù)降低成本的需求。難度相對于C/S也較低,自然開(kāi)發(fā)成本也較低。如果客戶(hù)能說(shuō)出這樣的要求肯定不是小白客戶(hù)。當然想要做IOS開(kāi)發(fā)的客戶(hù)基本上市對這個(gè)行業(yè)比較了解或者是有特別的用途。
在這個(gè)IOS開(kāi)發(fā)中,客戶(hù)提出了一個(gè)參考APP應用,即“快速問(wèn)醫生”。下載看了下,是個(gè)看病收費的一款app,但是費用相對不高,因為就是以咨詢(xún)?yōu)橹?。當然你要提?wèn)、咨詢(xún)等等也是要先注冊的。
關(guān)于IOS開(kāi)發(fā)中的這個(gè)注冊功能是較容易實(shí)現的。就是先把登錄界面文本框、按妞等讓美工做出圖,接下來(lái)給注冊按鈕編輯個(gè)單擊事件,跳轉到注冊的頁(yè)面,再注冊頁(yè)面中加入登錄名、密碼、驗證等控件,提交按鈕(也要加入單擊事件),在單擊事件中,要連接數據庫,并把上面填寫(xiě)的內容存到數據庫,在判斷當前的數據庫中是否存在相同的用戶(hù)名,如果沒(méi)有,可將上面填寫(xiě)的內容傳輸到數據庫。這個(gè)不管是IOS開(kāi)發(fā)還是網(wǎng)站注冊頁(yè)面的開(kāi)發(fā)都是這樣一個(gè)流程。實(shí)現的代碼如下:
//創(chuàng )建輸入框
- (void)addInputOne
{
//基本參數定義
CGFloat padx = 95.0f;
_vFrame = CGRectMake(10, 14, 300, 125);
UIFont *lpFont = [UIFont boldSystemFontOfSize:16];
//郵箱和密碼背景顏色設置
_view = [[UIView alloc] initWithFrame:_vFrame];
_view.layer.cornerRadius = 8.0;
_view.layer.borderWidth = 1;
_view.layer.borderColor = [UIColor colorWithRed:209.0f/255.0f green:209.0f/255.0f
blue:209.0f/255.0f alpha:1.0f].CGColor;
[_view setBackgroundColor:[UIColor colorWithRed:247.0f/255.0f green:247.0f/255.0f
blue:247.0f/255.0f alpha:1.0f]];
[self.view addSubview:_view];
[_view release];
//用戶(hù)名與密碼中間分割線(xiàn)
UIView *lineOne = [[UIView alloc] initWithFrame:CGRectMake(10, 53, 300, 1)];
[lineOne setBackgroundColor:[UIColor colorWithRed:209.0f/255.0f green:209.0f/255.0f
blue:209.0f/255.0f alpha:1.0f]];
[self.view addSubview:lineOne];
[lineOne release];
//用戶(hù)名
UILabel *_unameLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 2, 55, 40)];
[_unameLab setText:@"用戶(hù)名"];
_unameLab.highlighted = YES;
_unameLab.highlightedTextColor = [UIColor blackColor];
[_unameLab setFont:lpFont];
[_unameLab setBackgroundColor:[UIColor clearColor]];
[_unameLab setTextColor:[UIColor blackColor]];
[_view addSubview:_unameLab];
[_unameLab release];
_uname = [[UITextField alloc] initWithFrame:CGRectMake(padx, 10, 230, 40)];
[_uname setBackgroundColor:[UIColor clearColor]];
[_uname setTag:101];
[_uname setUserInteractionEnabled:YES];
[_uname setKeyboardType:UIKeyboardTypeDefault];
[_uname setReturnKeyType:UIReturnKeyNext]; //鍵盤(pán)下一步Next
[_uname setAutocapitalizationType:UITextAutocapitalizationTypeNone]; //關(guān)閉首字母大寫(xiě)
[_uname setAutocorrectionType:UITextAutocorrectionTypeNo];
[_uname setReturnKeyType:UIReturnKeyNext]; //下一個(gè)Passwd
[_uname becomeFirstResponder]; //默認打開(kāi)鍵盤(pán)
[_uname setFont:[UIFont systemFontOfSize:17]];
[_uname setDelegate:self];
[_uname setText:@""];
[_uname setHighlighted:YES];
[_view addSubview:_uname];
//密碼
UILabel *_passwdLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 43, 45, 40)];
[_passwdLab setText:@"密 碼"];
[_passwdLab setFont:lpFont];
_passwdLab.highlighted = YES;
_passwdLab.highlightedTextColor = [UIColor blackColor];
[_passwdLab setBackgroundColor:[UIColor clearColor]];
[_passwdLab setTextColor:[UIColor blackColor]];
[_view addSubview:_passwdLab];
[_passwdLab release];
_passwd = [[UITextField alloc] initWithFrame:CGRectMake(padx, 53, 200, 40)];
[_passwd setBackgroundColor:[UIColor clearColor]];
[_passwd setKeyboardType:UIKeyboardTypeDefault];
[_passwd setBorderStyle:UITextBorderStyleNone];
[_passwd setAutocapitalizationType:UITextAutocapitalizationTypeNone]; //關(guān)閉首字母大寫(xiě)
[_passwd setReturnKeyType:UIReturnKeyNext]; //下一個(gè)Email
[_passwd setSecureTextEntry:YES]; //驗證
[_passwd setDelegate:self];
[_passwd setTag:102];
[_passwd setTextColor:[UIColor grayColor]];
[_passwd setFont:lpFont];
[_passwd setText:@""];
[_view addSubview:_passwd];
//郵箱與密碼中間分割線(xiàn)
UIView *lineTow = [[UIView alloc] initWithFrame:CGRectMake(10, 95, 300, 1)];
[lineTow setBackgroundColor:[UIColor colorWithRed:209.0f/255.0f green:209.0f/255.0f
blue:209.0f/255.0f alpha:1.0f]];
[self.view addSubview:lineTow];
[lineTow release];
//用戶(hù)郵箱
UILabel *_emailLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 82, 280, 40)];
[_emailLab setText:@"電子郵箱"];
_emailLab.highlighted = YES;
_emailLab.highlightedTextColor = [UIColor blackColor];
[_emailLab setFont:lpFont];
[_emailLab setBackgroundColor:[UIColor clearColor]];
[_emailLab setTextColor:[UIColor blackColor]];
[_view addSubview:_emailLab];
[_emailLab release];
_email = [[UITextField alloc] initWithFrame:CGRectMake(padx, 92, 200, 40)];
[_email setBackgroundColor:[UIColor clearColor]];
[_email setKeyboardType:UIKeyboardTypeEmailAddress];
[_email setTextColor:[UIColor grayColor]];
[_email setTag:103];
[_email setReturnKeyType:UIReturnKeyDone]; //鍵盤(pán)下一步Next
[_email setAutocapitalizationType:UITextAutocapitalizationTypeNone]; //關(guān)閉首字母大寫(xiě)
[_email setAutocorrectionType:UITextAutocorrectionTypeNo];
[_email setFont:[UIFont systemFontOfSize:17]];
[_email setDelegate:self];
[_email setPlaceholder:@"[email protected]"];
[_email setText:@""];
[_email setHighlighted:YES];
[_view addSubview:_email];
}
//創(chuàng )建輸入框
- (void)addInputTow
{
//基本參數定義
CGFloat padx = 100.0f;
_vFrame = CGRectMake(10, 10, 300, 125);
UIFont *lpFont = [UIFont boldSystemFontOfSize:16];
//寶貝小名、寶貝性別、寶貝生日背景顏色設置
_view = [[UIView alloc] initWithFrame:_vFrame];
_view.layer.cornerRadius = 8.0;
_view.layer.borderWidth = 1;
_view.layer.borderColor = [UIColor colorWithRed:209.0f/255.0f green:209.0f/255.0f
blue:209.0f/255.0f alpha:1.0f].CGColor;
[_view setBackgroundColor:[UIColor colorWithRed:247.0f/255.0f green:247.0f/255.0f
blue:247.0f/255.0f alpha:1.0f]];
[self.view addSubview:_view];
[_view release];
//寶貝小名和寶貝性別分割線(xiàn)
UIView *lineOne = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 300, 1)];
[lineOne setBackgroundColor:[UIColor colorWithRed:209.0f/255.0f green:209.0f/255.0f
blue:209.0f/255.0f alpha:1.0f]];
[self.view addSubview:lineOne];
[lineOne release];
//寶貝小名
UILabel *_nicknameLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 2, 75, 40)];
[_nicknameLab setText:@"寶貝小名"];
_nicknameLab.highlighted = YES;
_nicknameLab.highlightedTextColor = [UIColor blackColor];
[_nicknameLab setFont:lpFont];
[_nicknameLab setBackgroundColor:[UIColor clearColor]];
[_nicknameLab setTextColor:[UIColor blackColor]];
[_view addSubview:_nicknameLab];
[_nicknameLab release];
_nickname = [[UITextField alloc] initWithFrame:CGRectMake(padx, 13, 180, 40)];
[_nickname setBackgroundColor:[UIColor clearColor]];
[_nickname setTag:101];
[_nickname setUserInteractionEnabled:YES];
[_nickname setKeyboardType:UIKeyboardTypeDefault];
[_nickname setReturnKeyType:UIReturnKeyNext]; //鍵盤(pán)下一步Next
[_nickname setAutocapitalizationType:UITextAutocapitalizationTypeNone]; //關(guān)閉首字母大寫(xiě)
[_nickname setAutocorrectionType:UITextAutocorrectionTypeNo];
[_nickname setReturnKeyType:UIReturnKeyNext]; //下一個(gè)寶貝性別
[_nickname becomeFirstResponder]; //默認打開(kāi)鍵盤(pán)
[_nickname setFont:[UIFont systemFontOfSize:17]];
[_nickname setDelegate:self];
[_nickname setText:@""];
[_nickname setHighlighted:YES];
[_view addSubview:_nickname];
//寶貝性別
UILabel *_sexLab = [[UILabel alloc] initWithFrame:CGRectMake(20, 35, 75, 50)];
[_sexLab setText:@"寶貝性別"];
[_sexLab setFont:lpFont];
_sexLab.highlighted = YES;
_sexLab.highlightedTextColor = [UIColor blackColor];
[_sexLab setBackgroundColor:[UIColor clearColor]];
[_sexLab setTextColor:[UIColor blackColor]];
[_view addSubview:_sexLab];
[_sexLab release];
_segment = [[UISegmentedControl alloc] initWithItems:
[NSArray arrayWithObjects:
@"男",@"女",
nil]];
_segment.frame = CGRectMake(padx+10, 56, 130, 32);
_segment.segmentedControlStyle = UISegmentedControlStylePlain;
_segment.selectedSegmentIndex = 1;
[self.view addSubview:_segment];
[_segment release];
//寶貝性別與寶貝生日中間分割線(xiàn)
UIView *lineTow = [[UIView alloc] initWithFrame:CGRectMake(10, 93, 300, 1)];
[lineTow setBackgroundColor:[UIColor colorWithRed:209.0f/255.0f green:209.0f/255.0f
blue:209.0f/255.0f alpha:1.0f]];
[self.view addSubview:lineTow];
[lineTow release];
//寶貝生日
UILabel *_birthLab = [[UILabel alloc] initWithFrame:CGRectMake(30, 96, 75, 40)];
[_birthLab setText:@"寶貝生日"];
_birthLab.highlighted = YES;
_birthLab.highlightedTextColor = [UIColor blackColor];
[_birthLab setFont:lpFont];
[_birthLab setBackgroundColor:[UIColor clearColor]];
[_birthLab setTextColor:[UIColor blackColor]];
[self.view addSubview:_birthLab];
[_birthLab release];
_birthDay = [[UIButton alloc] initWithFrame:CGRectMake(57, 96, 200, 40)];
[_birthDay setBackgroundColor:[UIColor clearColor]];
[_birthDay setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[_birthDay setTitle:@"2004-10-09" forState:UIControlStateNormal];
[_birthDay setTag:104];
[_birthDay addTarget:self action:@selector(openBirthday)
forControlEvents:UIControlEventTouchUpInside];
[_birthDay setHighlighted:YES];
[self.view addSubview:_birthDay];
//寶貝信息提示
UILabel *_babyNote = [[UILabel alloc] initWithFrame:CGRectMake(45, 131, 300, 40)];
[_babyNote setBackgroundColor:[UIColor clearColor]];
[_babyNote setTextColor:[UIColor colorWithRed:83.0f/255.0f green:92.0f/255.0f blue:112.0f/255.0f
alpha:1.0f]];
[_babyNote setTag:104];
[_babyNote setFont:[UIFont systemFontOfSize:14]];
[_babyNote setText:@"推薦引擎會(huì )根據孩子信息進(jìn)行個(gè)性推薦"];
[_babyNote setHighlighted:YES];
[self.view addSubview:_babyNote];
[_babyNote release];
//初始日期選擇控件
_datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0.0, 200.0, 0.0, 0.0)];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
//將當前生日時(shí)間設置到日期輪軸上
_datePicker.date = [dateFormatter dateFromString:_birthDay.titleLabel.text];
//設置為中文顯示
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
_datePicker.locale = locale;
[locale release];
[_datePicker setDatePickerMode:UIDatePickerModeDate];
[_datePicker addTarget:self action:@selector(dataValueChanged)
forControlEvents:UIControlEventValueChanged];
[self.view addSubview:_datePicker];
}
如果以上的代碼不夠詳細,你可以在百度搜索“IOS開(kāi)發(fā) 登錄注冊功能”,查看更為詳細的信息。
另外,當我把這款問(wèn)醫生的APP給我們負責IOS開(kāi)發(fā)的程序員查看的時(shí)候,他的第一反應是界面很美觀(guān)。如果做安卓或者是IOS開(kāi)發(fā)的想要參考一些好看尤其是在線(xiàn)交流的頁(yè)面,可以參考整形美容、餐飲預訂或者是這一款問(wèn)醫生的APP。
在客戶(hù)給的參考應用中,界面有個(gè)非常美觀(guān)的地方,在免費咨詢(xún)醫生問(wèn)題后一般的UI設計都是在回答問(wèn)題的下方,設置客戶(hù)留言的版塊,但是在參考應用中,他是類(lèi)似于淘寶,將醫生的回答和瀏覽者的評價(jià)是以左右兩側導航欄的形式實(shí)現的。很多設計的人會(huì )提出,你再好的設計也要遵循瀏覽者的習慣性瀏覽方式,但是筆者認為,能使用APP的人目前年齡層不會(huì )太大,本來(lái)這個(gè)東西就是新鮮的,你的設計就會(huì )慢慢培養客戶(hù)的習慣。具體的做法如下:
將SideNav設計成一個(gè)ViewController控件,用來(lái)管理控制LeftVC,RootVC,RightVC這3個(gè)ViewController;重置內容頁(yè)即rootViewController的NavBar,Setter入內容,左,右側導航欄控制器。如只是SetLeft,那么只會(huì )顯示左側按鈕;本身自帶一個(gè)View,因為SideNav本身也是一個(gè)ViewController,在默認set了RootViewController時(shí)(或者說(shuō)是內容ViewController),將RootViewController的View依附到SideNav的View上面;點(diǎn)擊左側菜單控制界面的某個(gè)菜單按鈕跳轉切換,以前看到的一個(gè)代碼例子類(lèi)似是使用了全局控制器的思路,可考慮使用委托來(lái)實(shí)現或者直接根據Appdelegate拿到SideNavVC的對象來(lái)操作。
這個(gè)的實(shí)現相較于注冊難度要大很多在IOS開(kāi)發(fā)中,但是這兩個(gè)功能的實(shí)現是在A(yíng)PP開(kāi)發(fā)中是最常見(jiàn)的?;旧隙紩?huì )有這樣的功能要求。在這篇文章中,以客戶(hù)案例為例,就是讓大家更直觀(guān)地了解在IOS開(kāi)發(fā)案例,切換的兩側導航和注冊功能實(shí)現的具體做法。