у меня было несколько изображений в строке результатов, я хочу отобразить их в виде таблицы - PullRequest
0 голосов
/ 31 марта 2011

У меня было несколько изображений в строке результатов, строка результатов - это то, что я получаю с сервера, оно содержит изображения, я хочу эти изображения и отображаю их в виде таблицы

мой код

viewdidload
{
NSString *urlVal = @"http://at.azinova.info/green4care/iphone/viewImage.php?id=";
    NSString *urlVal1 = [urlVal stringByAppendingString:selectedCountryw];
    NSURL *url1 = [NSURL URLWithString:urlVal1];
    //NSURL *url1 = [NSURL URLWithString:urlVal];



    NSString *resultString = [NSString stringWithContentsOfURL:url1 encoding:NSUTF8StringEncoding error:nil];


    NSArray *arycountries1 = [resultString componentsSeparatedByString:@","];
    UIAlertView *loginalert = [[UIAlertView alloc] initWithTitle:@" Message" message:resultString delegate:self
                                               cancelButtonTitle:@"OK" otherButtonTitles:nil];

    [loginalert show];

    [loginalert release];

    //arraycountries = [[NSArray alloc]initWitho:arycountries1];
    arraycountries = [[NSArray alloc]initWithArray: arycountries1];
    }

- (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 [arraycountries count];
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.imageView.image = [UIImage imageNamed:[arraycountries objectAtIndex:indexPath.row]];
    // Configure the cell...

    return cell;
}

помогите пожалуйста

thankzzzzz

1 Ответ

0 голосов
/ 31 марта 2011

То, что вы описали, во многом похоже на сообщение с изображениями, есть твиттер-проект с открытым исходным кодом в Твиттере: http://code.google.com/p/tweetero/ Вы можете взглянуть на MessageListController и ImageLoader.В общем, вы могли бы сделать так:1) Отправить асинхронный запрос на сервер, чтобы получить дату сообщения (не изображения)2) перезагрузите данные таблицы и отправьте запрос загрузчика изображений для каждого просмотра uiimage.3) установить uiimageview при загрузке изображения.Загружаемое изображение по умолчанию можно использовать до тех пор, пока не будет загружено реальное изображение.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...