Cocoa touch UIImage加载到标签上

Cocoa touch UIImage加载到标签上,cocoa-touch,uiimageview,uitableview,Cocoa Touch,Uiimageview,Uitableview,我有一个TableViewController,它使用JSON从主机上的服务器加载内容。 一切正常,但是UIImage应该在我的标签上的所有负载下。 为什么会发生这种情况?如何更改对象的顺序? 在我的故事板中,一切都是正确的,只有在加载内容时才会发生此更改 这是代码 - (void)viewDidLoad { [super viewDidLoad]; // CHECK INTERNET CONNECTION if ([self IsConnected]) {

我有一个TableViewController,它使用JSON从主机上的服务器加载内容。 一切正常,但是UIImage应该在我的标签上的所有负载下。 为什么会发生这种情况?如何更改对象的顺序? 在我的故事板中,一切都是正确的,只有在加载内容时才会发生此更改

这是代码

- (void)viewDidLoad
{
    [super viewDidLoad];

    // CHECK INTERNET CONNECTION
    if ([self IsConnected]) {
        [self retrieveData];
    }
    else {
        UIAlertView *alerta = [[UIAlertView alloc] initWithTitle:@"MSG ERRO" message:@"Conecte a Internet" delegate:nil cancelButtonTitle:@"fechar" otherButtonTitles:nil, nil];

        [alerta show];
    }

}

#pragma mark - PULL TO REFRESH

- (void)refresh
{
    if ([self IsConnected]) {
        [self retrieveData];
        [self.refreshControl endRefreshing];
    }
    else {
        UIAlertView *alerta = [[UIAlertView alloc] initWithTitle:@"MSG ERRO" message:@"Conecte a Internet" delegate:nil cancelButtonTitle:@"fechar" otherButtonTitles:nil, nil];
        [alerta show];

        [self.refreshControl endRefreshing];
    }
}

#pragma mark - CHECK INTERNET CONNECTION METHOD

- (BOOL)IsConnected
{
    Reachability *reachability = [Reachability reachabilityForInternetConnection];
    NetworkStatus networkStatus = [reachability currentReachabilityStatus];

    return !(networkStatus == NotReachable);
}

#pragma mark - TABLE VIEW

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return programacaoArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"TableCell";
    TableCell *cell = (TableCell *)[self.tableView dequeueReusableCellWithIdentifier:identifier];

    if (cell == nil) {
        cell = [[TableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }

    cell.backgroundColor = [UIColor clearColor];

    // CONFIGURE THE CELL
    Programacao *programacaoObject;
    programacaoObject = [programacaoArray objectAtIndex:indexPath.row];

    cell.imageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:programacaoObject.programacaoImagem]]];
    cell.nomeLabel.text = programacaoObject.programacaoNome;
    cell.dataLabel.text = programacaoObject.programacaoData;
    cell.localLabel.text = programacaoObject.programacaoLocal;

    return cell;

}

#pragma mark - LOADS THE DATA FROM SERVER

- (void) retrieveData
{

    NSURL *url = [NSURL URLWithString:getDataURL];
    NSData *data = [NSData dataWithContentsOfURL:url];

    jsonArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];

    // SETUP programacaoArray
    programacaoArray = [[NSMutableArray alloc] init];

    // Loop Array
    for (int i = 0; i < jsonArray.count; i++) {
        // Cria o PROGRAMACAO Objeto
        NSString *pID         = [[jsonArray objectAtIndex:i] objectForKey:@"id"];
        NSString *pNome       = [[jsonArray objectAtIndex:i] objectForKey:@"programacaoNome"];
        NSString *pImagem     = [[jsonArray objectAtIndex:i] objectForKey:@"programacaoImagem"];
        NSString *pDescricao  = [[jsonArray objectAtIndex:i] objectForKey:@"programacaoDescricao"];
        NSString *pData       = [[jsonArray objectAtIndex:i] objectForKey:@"programacaoData"];
        NSString *pLocal      = [[jsonArray objectAtIndex:i] objectForKey:@"programacaoLocal"];
        NSString *pPrecos     = [[jsonArray objectAtIndex:i] objectForKey:@"programacaoPrecos"];

        // ADD THE CONTENT
        [programacaoArray addObject:[[Programacao alloc] initWithNome:pNome andImagem:pImagem andDescricao:pDescricao andData:pData andLocal:pLocal andPrecos:pPrecos andID:pID]];
    }

// RELOAD TABLE VIEW
[self.tableView reloadData];
-(void)viewDidLoad
{
[超级视图下载];
//检查互联网连接
如果([自断开]){
[自检索数据];
}
否则{
UIAlertView*alerta=[[UIAlertView alloc]initWithTitle:@“MSG ERRO”消息:@“连接Internet”委托:无取消按钮:@“fechar”其他按钮:无,无];
[警报秀];
}
}
#pragma标记-拖动以刷新
-(无效)刷新
{
如果([自断开]){
[自检索数据];
[自我刷新控制结束刷新];
}
否则{
UIAlertView*alerta=[[UIAlertView alloc]initWithTitle:@“MSG ERRO”消息:@“连接Internet”委托:无取消按钮:@“fechar”其他按钮:无,无];
[警报秀];
[自我刷新控制结束刷新];
}
}
#pragma标记-检查INTERNET连接方法
-(BOOL)断开连接
{
可达性*可达性=[可达性可达性Internet连接];
NetworkStatus NetworkStatus=[reachability currentReachabilityStatus];
return!(networkStatus==NotReachable);
}
#pragma标记-表视图
-(NSInteger)表格视图中的节数:(UITableView*)表格视图
{
返回1;
}
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
返回程序acoaarray.count;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*标识符=@“TableCell”;
TableCell*单元格=(TableCell*)[self.tableView dequeueReusableCellWithIdentifier:identifier];
如果(单元格==nil){
cell=[[TableCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:标识符];
}
cell.backgroundColor=[UIColor clearColor];
//配置单元格
Programacao*programacaoObject;
programacaoObject=[ProgramAcoaarray对象索引:indexPath.row];
cell.imageView.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:ProgramAcooObject.programacaoImagem]];
cell.nomeLabel.text=ProgramAcoobject.ProgramAconome;
cell.dataLabel.text=programacaoObject.programacaoData;
cell.localLabel.text=ProgramAcoobject.ProgramAcolocal;
返回单元;
}
#pragma标记-从服务器加载数据
-(无效)检索数据
{
NSURL*url=[NSURL URLWithString:getDataURL];
NSData*data=[NSData dataWithContentsOfURL:url];
jsonArray=[NSJSONSerialization JSONObjectWithData:数据选项:针织错误:nil];
//安装程序Acoarray
ProgramAcoarray=[[NSMutableArray alloc]init];
//循环阵列
for(int i=0;i
}

这是我的屏幕。

您确定
ProgramAcoobject.ProgramAconome
ProgramAcoobject.ProgramAcoodata
ProgramAcoobject.ProgramAcolocal
不是空的吗?

您在
TableCell
类中做过任何布局吗?不,我只是在.h文件中创建了我的IBoutlet<代码>@property(强,非原子)IBOutlet UILabel*nomeLabel@属性(强,非原子)IBUILabel*dataLabel@属性(强,非原子)IBUILabel*localLabel@属性(强,非原子)IBUIImageView*atracaoImagem