0

テーブルが部分的に読み込まれ、数回上下にスクロールした後に残りが読み込まれるようです。間違いなく、これは私[[self myTableView] reloadData];と私の間の配置に関係して-(void)viewWillAppear:(BOOL)animated,-(void)viewDidAppear:(BOOL)animated,-(void)viewDidLoadいますが、指を置くことはできません. この場合、データの要求は行われません。アプリの起動時に、指定されたすべてのデータを一度にロードしようとしているだけです。

#import "PreViewController.h"
#import <CoreData/CoreData.h>
#import <CoreLocation/CoreLocation.h>
#import "FlipsideViewController.h"
#import "AppDelegate.h"
#import <SystemConfiguration/SystemConfiguration.h>
#import "Reachability.h"

@interface PreViewController ()

{
    NSMutableArray *arrayNo;
}

@end

@implementation PreViewController

-(void)viewWillAppear:(BOOL)animated
{
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkForReachability) name:kReachabilityChangedNotification object:nil];

    Reachability *reachability = [Reachability reachabilityForInternetConnection];
    [reachability startNotifier];

    NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];

    if(remoteHostStatus == NotReachable)
    {
        UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle: @"Please check your network connection and try again."
                          message: @""
                          delegate: nil
                          cancelButtonTitle:@"OK"
                          otherButtonTitles:nil];
        [alert show];
    }
 }

-(void)viewDidAppear:(BOOL)animated
{    

   NSString *arts = [NSString stringWithFormat:@"Arts and Museums"];
   NSString *coffee = [NSString stringWithFormat:@"Coffee and Bakeries"];
   NSString *tours = [NSString stringWithFormat:@"Tours and Festivals"];
   NSString *hotels = [NSString stringWithFormat:@"Hotels and Inns"];
   NSString *leisure = [NSString stringWithFormat:@"Leisure and Recreation"];
   NSString *music = [NSString stringWithFormat:@"Live Music"];
   NSString *bars = [NSString stringWithFormat:@"Night Clubs and Bars"];
   NSString *food = [NSString stringWithFormat:@"Restaurants"];
   NSString *shopping = [NSString stringWithFormat:@"Shopping"];
   NSString *transportation = [NSString stringWithFormat:@"Transportation"];

   [arrayNo addObject:arts];
   [arrayNo addObject:coffee];
   [arrayNo addObject:tours];
   [arrayNo addObject:hotels];
   [arrayNo addObject:leisure];
   [arrayNo addObject:music];
   [arrayNo addObject:bars];
   [arrayNo addObject:food];
   [arrayNo addObject:shopping];
   [arrayNo addObject:transportation];

   [[self myTableView] reloadData];
}

- (void)viewDidLoad
{
   [super viewDidLoad];
   arrayNo = [[NSMutableArray alloc] init];

   [[self myTableView] setDelegate:self];
   [[self myTableView] setDataSource:self];
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
   return 1;

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [arrayNo count];
}

- (UIFont *)fontForCell
{
   return [UIFont boldSystemFontOfSize:14.0];
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  static NSString *CellIdentifier = @"Cell";
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

  if (!cell)
  {
      NSLog(@"CREATING NEW CELL");
      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  }
  else
  {
      cell.textLabel.text = [arrayNo objectAtIndex:indexPath.row];
      cell.textLabel.textColor = [UIColor whiteColor];
      cell.textLabel.textAlignment = NSTextAlignmentCenter;
      cell.textLabel.textColor = [UIColor colorWithRed:(100/255.0) green:(130/255.0) blue:(255/255.0) alpha:1.0];
  }
  return cell;
}


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

@end
4

1 に答える 1