开发者

i had some images in resultstring i want to display it in tableview

开发者 https://www.devze.com 2023-02-20 18:15 出处:网络
i had some images in resultstring ,resultstring is what i get from the server ,it contains images ,i want that images and display it in tableview

i had some images in resultstring ,resultstring is what i get from the server ,it contains images ,i want that images and display it in tableview

my code is

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 开发者_如何学Pythonencoding: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;
}

please help

thankzzzzz


What you described is much like a message borad with images, there is a twitter open source project tweetero: http://code.google.com/p/tweetero/ You can take a look at MessageListController and ImageLoader.
In generally, you could do like this:
1) Send async request to server to get message date(not images)
2) reload the table data, and send the image loader request for each uiimageview.
3) set the uiimageview when the image is loaded. A default loading image can be used until the real image is loaded.

0

精彩评论

暂无评论...
验证码 换一张
取 消