Перенос данных из одного просмотра в другой - PullRequest
0 голосов
/ 08 сентября 2011

У меня есть таблица со списком рекламных акций, хранящихся в NSSet, которые я загружаю в массив для отображения названия / имени в ячейке. Однако я хочу использовать метод didselectrow, чтобы перенести выбранное продвижение на отдельную страницу продвижения. Я делаю promo.featuredArray = self.featuredArray, но, похоже, данные не передаются. Мой код выглядит следующим образом.

Промо-лист.m

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *CellIdentifier = @"CellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }
    Featured*featured = [self.featuredArray objectAtIndex:indexPath.row];
    cell.textLabel.text = featured.details;
    cell.textLabel.textColor = [UIColor whiteColor];
    cell.detailTextLabel.text = self.place.name;
    return cell;

}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    Promo * promo= [[Promo alloc] initWithNibName:@"Promo" bundle:nil];
    //Featured*featured = [self.featuredArray objectAtIndex:indexPath.row]; 
    promo.featuredArray = self.featuredArray;
    [self.navigationController pushViewController:promo animated:YES];
    [promo release];
    //[featured release];
}

Promo.m

@synthesize featuredArray, featured = __featured;

    - (void)viewDidLoad
    {

        self.clearImage = [UIImage imageNamed:@"fav_icon.png"];
        self.clearImagePressed = [UIImage imageNamed:@"fav_icon_sel.png"];
        Featured*featured = [self.featuredArray init];
        self.name.text = [NSString stringWithFormat:@"%@", __featured.name];
        self.time.text = [NSString stringWithFormat:@"%@", __featured.time];
        // self.description.text = [NSString stringWithFormat:@"%@", __featured.description];
        self.placeName.text = [NSString stringWithFormat:@"%@", __featured.Place];

        [super viewDidLoad];


        if([__featured.imageURL hasPrefix:@"http"])
        {
            [self getImageForPlace];
        }
    //    else
    //    {
    //        [self refreshImage];  
    //    }
    //    
        self.title = @"Promotion";

        UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background_texture.png"]];
        self.view.backgroundColor = background;
        [background release];
        [featured release];
    }

1 Ответ

0 голосов
/ 08 сентября 2011

Это, вероятно, следующая строка:

Featured*featured = [self.featuredArray init];

Во многих отношениях это неправильно.

Создание вики сообщества, потому что у меня нет времени написать полный ответ.

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