en travaillant à travers plusieurs autres problèmes que je me suis trouvé à ce stade. J'ai beaucoup appris sur les choses que j'essaie de faire, mais je suis complètement perplexe. J'écris un format de champ de texte pour une connexion que je voudrais avoir sur mon application, et parce que Apple n'a rien qui ressemble à un masque de champ de texte, j'ai décidé d'écrire ma propre cellule personnalisée qui ressemble à une masque dessus mais tout ce que je vais faire est de concaténer des champs de texte en arrière-plan.Demande de membre 'uitextfield' dans quelque chose, pas une structure ou une union?
Cependant, j'ai rencontré un problème. J'essaie d'appeler textField: shouldChangeCharactersInRange: replacementString: d'un UITextField dans mon UITableViewCell sous-classé comme indiqué dans mon code ci-dessous. Cependant, je reçois une demande pour un membre 'uitextfield' dans quelque chose qui n'est pas une structure ou une erreur syndicale ... toute aide serait appréciée.
////.h
@interface RegisterDeviceViewController : UIViewController <UITableViewDelegate, UITextFieldDelegate> {
RegisterDeviceViewController *registerDeviceViewController;
//UITextFields for the registration cell
UITextField *regFieldOne;
UITextField *regFieldTwo;
UITextField *regFieldThree;
UITextField *regFieldFour;
UITableViewCell *myRegistrationField;
UITableViewCell *mySubmitButton;
}
//UITextFields for the registration cell
@property (nonatomic, retain) IBOutlet UITextField *regFieldOne;
@property (nonatomic, retain) IBOutlet UITextField *regFieldTwo;
@property (nonatomic, retain) IBOutlet UITextField *regFieldThree;
@property (nonatomic, retain) IBOutlet UITextField *regFieldFour;
@property (nonatomic, retain) IBOutlet UITableViewCell *myRegistrationField;
@property (nonatomic, retain) IBOutlet UITableViewCell *mySubmitButton;
@end
/////.m
#import "RegisterDeviceViewController.h"
@implementation RegisterDeviceViewController
//Custom registration cell fields
@synthesize regFieldOne;
@synthesize regFieldTwo;
@synthesize regFieldThree;
@synthesize regFieldFour;
@synthesize myRegistrationField;
@synthesize mySubmitButton;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
self.title = @"Registration";
[super viewDidLoad];
}
//Sets number of sections in the table
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
// Sets the number of rows in each section.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
//Loads both Custom cells into each section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"mythingy"];
if (cell == nil) {
cell = myRegistrationField;
}
UITableViewCell *cellButton = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"mummy"];
if (cellButton == nil) {
cellButton = mySubmitButton;
}
if (indexPath.section == 0) {
return cell;
cell.regFieldOne.delegate = self; //This is where the error is.
}
return cellButton;
}
//This delegate method is not being called.
//textField:shouldChangeCharactersInRange:replacementString:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
int length = [regFieldOne.text length] ;
if (length >= MAXLENGTH && ![string isEqualToString:@""]) {
regFieldOne.text = [regFieldOne.text substringToIndex:MAXLENGTH];
return NO;
}
return YES;
}
..........
Voulez-vous simplement masquer les caractères au fur et à mesure qu'ils sont saisis? Si oui, regardez cette propriété: @property (nonatomic, getter = isSecureTextEntry) BOOL secureTextEntry – DavidN
Non, je veux juste limiter chaque UItextfield à 5 caractères. – tinhead