“iLabel”在模拟器中显示,但一旦归档并运行 IPA 文件,它就无法显示。我尝试清理代码,但没有做任何事情。iLabel 的想法是在 UIIndicator 动画时显示,当然当指示器消失时也会消失。
- (void)viewDidLoad
{
[super viewDidLoad];
[[self myTableView] setDelegate:self];
[[self myTableView] setDataSource:self];
array = [[NSMutableArray alloc] init];
[self startActivity];
}
-(void)startActivity
{
indicator.hidden=NO;
[indicator startAnimating];
[self uploadData];
NSLog(@"VIEWDIDLOAD-INDICATOR-TURNING-ON: %@", indicator);
}
-(void)uploadData
{
NSLog(@"Uploading...");
[[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: @"Oops..."
message: @"Network connection lost."
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show]; }
else if (remoteHostStatus == ReachableViaWiFi)
{
iLabel.text = @"Please be patient...";
}
}
- (void) connectionDidFinishLoading:(NSURLConnection *)connection
{
[self setString];
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil];
NSString *string1 = [dic objectForKey:@"name"];
NSString *string7 = [dic objectForKey:@"review_count"];
NSString *string3 = [dic objectForKey:@"display_phone"];
NSDictionary *location = [dic objectForKey:@"location"];
NSArray *array2 = [location objectForKey:@"display_address"];
NSDictionary *coordinate = [location objectForKey:@"coordinate"];
lat = [coordinate objectForKey:@"latitude"];
lon = [coordinate objectForKey:@"longitude"];
mURL = [dic objectForKey:@"mobile_url"];
NSString *string4 = [array2 objectAtIndex:0];
NSString *string5 = [array2 objectAtIndex:1];
NSString *img2String = [dic objectForKey:@"image_url"];
for (NSDictionary *diction in dic)
{
NSString *string6 = [NSString stringWithFormat:@"Yelp Rating: "];
NSString *string8 = [NSString stringWithFormat:@"Based on %@ Review(s)", string7];
[array addObject:string1];
[array addObject:string6];
[array addObject:string8];
[array addObject:string3];
[array addObject:string4];
[array addObject:string5];
UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:img2String]]];
imageView.image = image;
}
for (NSDictionary *diction in coordinate)
{
[array addObject:lat];
[array addObject:lon];
}
[[self myTableView] reloadData];
[indicator stopAnimating];
indicator.hidden=YES;
[indicator removeFromSuperview];
iLabel.text = @"";
[iLabel removeFromSuperview];
}