2011-10-13 12 views
12

私はFacebookのアプリからのログイン画面を作りたいと思っています。私が複製したい部分は、スタックされたときにテーブルグループのように見える2つのテキストフィールドです。彼らはどうしたのか分かりません。iOS:ログイン画面の表形式のTextField?

トリックは誰が知っていますか?

私はstackoverflowを初めて利用しているため画像を投稿できません。 1つの丸い楕円形のように見えるが、内部に2つのテキストフィールドがあるという効果です。 1つはユーザー名用、もう1つはパスワード用です。

+0

このコントロールはすでに書かれています:http://cocoacontrols.com/platforms/ios/controls/ddalertprompt – Luke

+0

イメージをアップロードする場合は、リンクされている以下のコントロールを使用できますimage:http://img31.imageshack.us/img31/566/screenshot20111015at317.png – User97693321

答えて

11

次のコードを使用できます。 .Mファイル内の.hファイルで

//

UITextField *loginId; 
UITextField *password ; 

//

- (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"] autorelease]; 

     if (indexPath.row == 0) { 
      loginId = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)]; 
      loginId .placeholder = @"loginid"; 
      loginId .autocorrectionType = UITextAutocorrectionTypeNo; 
      [loginId setClearButtonMode:UITextFieldViewModeWhileEditing]; 
      cell.accessoryView = loginId ; 
     } 
     if (indexPath.row == 1) { 
      password = [[UITextField alloc] initWithFrame:CGRectMake(5, 0, 280, 21)]; 
      password.placeholder = @"Password"; 
      password.secureTextEntry = YES; 
      password.autocorrectionType = UITextAutocorrectionTypeNo; 
      [password setClearButtonMode:UITextFieldViewModeWhileEditing]; 
      cell.accessoryView = password; 
     } 
     loginId.delegate = self; 
     password.delegate = self; 


     [tableView1 addSubview:loginId]; 
     [tableView1 addSubview:password]; 
     [loginId release]; 
     [password release]; 

     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     return cell; 
    } 
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ 

     return 1; 
    } 
+0

コメントのコメントオプションを使用してください。 – JustSid

+0

偉大な答え、1つの質問。グループ化された2つのセルの位置を移動する方法はありますか、または画面の上部に留まらなければなりませんか? – BlueMeanie

3

背景に丸みを付けたUIVIewを使用し、2つのテキストフィールドをサブビューとして追加します。

-2

UITableViewを受け取り、UITextFieldaccessoryTypeとして追加することができます。

4

Ah!私は答えを得た。それはただの芸術です。これは、ボーダレスUITextFieldsと2セルのテーブルビューのように見えるUIImageです。なぜ私はそれが芸術であるとは思わないのですか?

9

ここからコードを取る:あなたはコードをダウンロードしに見ればhttps://github.com/c99koder/lastfm-iphone

をFirstRunView.xibには、希望どおりの実装が表示されます。

+5

lastfmコードを見ている人は誰でも頭を上げています。画像を使ってグループ化されたTableViewの効果を達成します。 –

関連する問題