我有一個屏幕,圖片和標籤在頂部和中間的某個地方,我想添加兩個文本框。我非常喜歡Facebook登錄屏幕的樣子,我想要做類似的事情,但這對我來說並不容易,作爲一個絕對的初學者。如何在Facebook登錄屏幕中創建一組文本字段?
我正在使用Storyboard和當前屏幕的視圖控制器實現UIViewController。
我想了解如何管理它,所以,任何提示是apreaciated。
謝謝。
LE:這是我試過的,但沒有結果: 我在屏幕上添加了一個表格視圖,並且我爲兩個文本字段創建了屬性,所以我可以動態地在兩個單元格中添加兩個文本字段。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Cell"];
if(cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
if (indexPath.row == 0) {
self.txtUsername = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 280, 20)];
self.txtUsername .placeholder = @"Username";
self.txtUsername .autocorrectionType = UITextAutocorrectionTypeNo;
[self.txtUsername setClearButtonMode:UITextFieldViewModeWhileEditing];
cell.accessoryView = self.txtUsername ;
}
if (indexPath.row == 1) {
self.txtPassword = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 280, 20)];
self.txtPassword.placeholder = @"Password";
self.txtPassword.secureTextEntry = YES;
self.txtPassword.autocorrectionType = UITextAutocorrectionTypeNo;
[self.txtPassword setClearButtonMode:UITextFieldViewModeWhileEditing];
cell.accessoryView = self.txtPassword;
}
[cell addSubview:self.txtUsername];
[cell addSubview:self.txtPassword];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
我不使用靜態細胞
,所以我理解了它的唯一方法就是以編程方式添加這些文本字段。
我應該用戶靜態單元格嗎?
你能上傳圖片嗎? –