SORU
3 Ocak 2009, CUMARTESİ


Bir UİTableViewCell bir UİTextField sahip

Yapmaya çalışıyorum şu birkaç gün oldu, ve sonra okuma ton mesajların insanların yapmaya çalışıyorum da, ben hala olamadım tam çalışma UITextField biraz UITableViewCells, tıpkı bu örnekte:

Screenshot

Ya ben form çalışıyor ama metin değil görünür (her ne kadar ben set rengi mavi), klavye gidiyor sahada ne zaman ı tıklatın ve ben fırsatım olmadı doğru uygulamak klavye olayları. Ama hala düzgün çalışmıyor Apple örnekleri bir grup ile çalıştım (başta biraz benzer bir kontrolü var UICatalog,).

Biri bana (ve tüm insanlar bu kontrolü gerçekleştirmek için çalışıyor) Yardım ve UITextField UITableViewCell, bu işleri bir güzel basit bir uygulama gönderebilir miyim?

CEVAP
9 ŞUBAT 2010, Salı


Bu denemek. Benim için bir cazibe gibi çalışır (iPhone cihazlarda). Bir oturum açma ekranı için bu kodu bir kez kullandım. İki bölüm için tablo görünümü oluşturdum. Tabii ki bölüm bilgi almak kurtulabilirsiniz.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:kCellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                   reuseIdentifier:kCellIdentifier] autorelease];
    cell.accessoryType = UITableViewCellAccessoryNone;

    if ([indexPath section] == 0) {
        UITextField *playerTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
        playerTextField.adjustsFontSizeToFitWidth = YES;
        playerTextField.textColor = [UIColor blackColor];
        if ([indexPath row] == 0) {
            playerTextField.placeholder = @"example@gmail.com";
            playerTextField.keyboardType = UIKeyboardTypeEmailAddress;
            playerTextField.returnKeyType = UIReturnKeyNext;
        }
        else {
            playerTextField.placeholder = @"Required";
            playerTextField.keyboardType = UIKeyboardTypeDefault;
            playerTextField.returnKeyType = UIReturnKeyDone;
            playerTextField.secureTextEntry = YES;
        }       
        playerTextField.backgroundColor = [UIColor whiteColor];
        playerTextField.autocorrectionType = UITextAutocorrectionTypeNo; // no auto correction support
        playerTextField.autocapitalizationType = UITextAutocapitalizationTypeNone; // no auto capitalization support
        playerTextField.textAlignment = UITextAlignmentLeft;
        playerTextField.tag = 0;
        //playerTextField.delegate = self;

        playerTextField.clearButtonMode = UITextFieldViewModeNever; // no clear 'x' button to the right
        [playerTextField setEnabled: YES];

        [cell.contentView addSubview:playerTextField];

        [playerTextField release];
    }
}
if ([indexPath section] == 0) { // Email & Password Section
    if ([indexPath row] == 0) { // Email
        cell.textLabel.text = @"Email";
    }
    else {
        cell.textLabel.text = @"Password";
    }
}
else { // Login button section
    cell.textLabel.text = @"Log in";
}
return cell;    
}

Sonuç bu gibi görünüyor:

login form

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • CHISTOSITOJAJA

    CHISTOSITOJA

    27 HAZİRAN 2010
  • Digital Bounds

    Digital Boun

    19 Temmuz 2013
  • Richard Laxa

    Richard Laxa

    30 AĞUSTOS 2012