0
성공적으로 텍스트가 내 UITableView
에서 작동하면 이미지가 작동하지 않습니다. UITableViewCellsForRow
에 LogoURL
배열이 비어있는 것 같습니다. 내 코드는 여기에 있습니다.UITableView의 이미지가 작동하지 않습니다.
#import "ViewController.h"
@interface ViewController()
@property (nonatomic, strong) MSTable *table;
@property (nonatomic, strong) NSMutableArray *items;
@property (weak, nonatomic) IBOutlet UITableView *MainTableView;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// create the activity indicator in the main queue
self.MainTableView.hidden = YES;
UIActivityIndicatorView *ac = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[self.view addSubview:ac];
[ac startAnimating];
self.client = [MSClient clientWithApplicationURLString:@"https://outnight-mobile.azure-mobile.net/" applicationKey:@"okYeRGfBagYrsbkaqWIRObeDtktjkF10"];
self.table = [self.client tableWithName:@"notifications"];
self.rowitems = [[NSMutableArray alloc] init];
MSQuery *query = [self.table query];
query.fetchLimit = 3;
[query readWithCompletion:^(NSArray *items, NSInteger totalCount, NSError *error)
{
self.rowitems = [items mutableCopy];
[self.MainTableView reloadData];
self.MainTableView.hidden = YES;
int a;
for (a = 0; a < 3; a++)
{
NSDictionary *apt = [self.rowitems objectAtIndex:a];
NSLog(@"%@", apt[@"barID"]);
NSDictionary *barIDDictionary = @{ @"myParam": apt[@"barID"]};
self.client = [MSClient clientWithApplicationURLString:@"https://outnight-mobile.azure-mobile.net/" applicationKey:@"okYeRGfBagYrsbkaqWIRObeDtktjkF10"];
[self.client invokeAPI:@"photos" body:barIDDictionary HTTPMethod:@"POST" parameters:nil headers:nil completion:^(id result, NSHTTPURLResponse *response, NSError *error) {
if (error) {
NSLog(@"Error %@", error);
}
else {
NSString *string = [NSString stringWithFormat:@"%@", [result objectForKey:@"rows"]];
NSString *stringWithoutbracketsend = [string stringByReplacingOccurrencesOfString:@")" withString:@""];
NSString *stringWithoutbracketsfront = [stringWithoutbracketsend stringByReplacingOccurrencesOfString:@"(" withString:@""];
NSString *completion = [stringWithoutbracketsfront stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *newStr = [completion substringFromIndex:1];
NSString *finalstring = [newStr substringToIndex:newStr.length-(newStr.length>0)];
[self.logoURL addObject:finalstring];
NSLog(@"%@",finalstring);
[self.MainTableView reloadData];
self.MainTableView.hidden = NO;
}
}];
}
}];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.rowitems count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
NSDictionary *stress = [self.rowitems objectAtIndex:indexPath.row];
cell.textLabel.text = stress[@"content"];
switch (indexPath.row) {
case 0:
[cell.imageView setImageWithURL:[NSURL URLWithString:[self.logoURL objectAtIndex:(1)]] placeholderImage:[UIImage imageNamed:@"greybox40.png"]];
NSLog(@"%@", [self.logoURL objectAtIndex:(1)]);
break;
case 1:
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"greybox40.png"]];
break;
case 2:
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] placeholderImage:[UIImage imageNamed:@"greybox40.png"]];
break;
}
return cell;
}
@end
첫 번째 사례 설명에서 볼 수 있듯이 배열 내용을 볼 수 있는지 확인할 수 없었습니다. 어떤 도움도 팹이 될 것입니다 - 나는 나의 리로드 테이블을 어디에 두 었는지 확신하지만 다시는 확신 할 수 없습니다.
여기서'self.logoURL'을 (를) 초기화 하시겠습니까? – Akhilrajtr
이고 문자 배열이 .h 파일에 – santhu
이어야합니다. 텍스트가 – user3307144