2011-06-14 1 views
0

Je pousse un simple UIViewController sur un contrôleur de navigation, et il y a environ 1 seconde de retard avant que l'animation de poussée commence. C'est après une nouvelle construction. Après l'avoir chargé une fois, il n'a plus de délai.Pourquoi y a-t-il un si long délai lorsqu'on appuie sur ce UIViewController?

Le contrôleur de vue racine dispose de 3 autres cellules de table qui poussent différents contrôleurs de vue sur la pile, et aucune d'entre elles n'a le même type de retard. De plus, cette VC en question est la plus simple (en termes de quantité de code) du 4.

je pousse tous les VCs en utilisant la technique:

if (!editExerciseViewController) { 
     editExerciseViewController = [[EditExerciseViewController alloc] initWithStyle:UITableViewStyleGrouped]; 
    } 

Voici le code du ViewController en question:

#import "EditExerciseViewController.h" 

@implementation EditExerciseViewController 
@synthesize exerciseField; 

- (id)initWithStyle:(UITableViewStyle)style 
{ 
    self = [super initWithStyle:style]; 
    if (self) { 
     [[self navigationItem] setTitle:@"Exercise"]; 
    } 
    return self; 
} 

- (void)dealloc 
{ 
    [super dealloc]; 
} 

#pragma mark - View lifecycle 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    // Return the number of sections. 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    // Return the number of rows in the section. 
    return 1; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = nil; 

    CGFloat viewWidth; 
    viewWidth = 130.0f; 
    CGRect frame = CGRectMake(0.0f, 0.0f, viewWidth, 21.0f); 

    if ([indexPath row] == 0) { 
     // If Exercise cell 
     if (cell == nil) 
     { 
      cell = [[UITableViewCell alloc] initWithFrame:CGRectZero]; 
     } 

     cell.textLabel.text = NSLocalizedString(@"Exercise", nil); 
     exerciseField = [[UITextField alloc] initWithFrame:frame]; 
     [exerciseField setKeyboardType:UIKeyboardTypeNumberPad]; 
     [exerciseField setTextAlignment:UITextAlignmentRight]; 
     [exerciseField setClearsOnBeginEditing:YES]; 
     [exerciseField setPlaceholder:NSLocalizedString(@"calories", nil)]; 
     [exerciseField setTextColor:[UIColor colorWithRed:0.20f green:0.31f blue:0.52f alpha:1.0f]]; 

     [cell setAccessoryView:exerciseField]; 
     [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
     [exerciseField becomeFirstResponder]; 

    } 

    return cell; 
} 

@end 

y at-il quelque chose dans ce code qui est à l'origine de ce retard?

Je le test sur un iPhone 3GS.

Répondre

0

Le problème est avec le clavier. La première fois que le clavier est chargé sur des appareils plus anciens, c'est lentwwww. Vous pouvez précharger le clavier dans votre application. Voici quelques conseils.

Link

Questions connexes