2014-01-06 25 views
0

У меня есть приложение, созданное с коллекционными видами, у которого есть серия ячеек, а затем переходы к другому с помощью полноэкранной ячейки для воссоздания фотогалереи. У меня это отлично работает на iPhone, но когда я пытаюсь щелкнуть iPad по первой ячейке, я должен распознать элемент в указательном пути и передать это на полный экран, чего не происходит.Идентификатор Segue на раскадровке iPad

Я считаю, что причина, по которой я ищу идентификатор segue, и поскольку это универсальное приложение, использую тот же код для обоих видов использования. На раскадровке iPhone я могу установить идентификатор segue, но это не отображается в раскадровке iPad. Вопрос в том…. Это нормально и есть ли способ вокруг него? Я могу предоставить код по запросу, но в данный момент он не считает его актуальным.

Кодекс:

Первая коллекция Просмотреть

@implementation Study3CollectionViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 


- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [self createData]; 
} 

- (void)createData { 

    self.dresserImages = [NSMutableArray array]; 

    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4723.JPG", @"image", nil]]; 
    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4726.JPG", @"image", nil]]; 
    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4729.JPG", @"image", nil]]; 
    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4730.JPG", @"image", nil]]; 
    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4731.JPG", @"image", nil]]; 


    [self.collectionView reloadData]; 

} 

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 
    return self.dresserImages.count; 
} 


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 
    static NSString *identifier = @"Cell"; 

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; 

    UIImageView *dresserImageView = (UIImageView *)[cell viewWithTag:100]; 
    dresserImageView.image = [UIImage imageNamed:[[self.dresserImages objectAtIndex:indexPath.row] objectForKey:@"image"]]; 

    return cell; 
} 

- (void)scrollViewDidScroll:(UIScrollView *)scrollView { 
    if (_startingIndexPath) { 
     NSInteger currentIndex = floor((scrollView.contentOffset.x - scrollView.bounds.size.width/1)/scrollView.bounds.size.width) + 1; 
     if (currentIndex < [self.dresserImages count]) { 
      self.title = self.dresserImages[currentIndex][@"name"]; 
     } 
    } 
} 

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    if ([segue.identifier isEqualToString:@"collectionView"]) 

    { 
     Study3DetailCollectionViewController *destViewController = (Study3DetailCollectionViewController *)segue.destinationViewController; 

     NSIndexPath *indexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex:0]; 

     destViewController.startingIndexPath = indexPath; 

     [destViewController.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; 

     [self.collectionView deselectItemAtIndexPath:indexPath animated:NO]; 
    } 
} 

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 

    [self.collectionView scrollToItemAtIndexPath:self.startingIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 

Детальный вид

@implementation Study3DetailCollectionViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 


- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [self createData]; 
} 

- (void)createData { 

    self.dresserImages = [NSMutableArray array]; 

    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4723.JPG", @"image", nil]]; 
    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4726.JPG", @"image", nil]]; 
    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4729.JPG", @"image", nil]]; 
    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4730.JPG", @"image", nil]]; 
    [self.dresserImages addObject:[[NSMutableDictionary alloc] 
            initWithObjectsAndKeys:@"Newton Wardrobes", @"name", 
            @"IMG_4731.JPG", @"image", nil]]; 


    [self.collectionView reloadData]; 

} 

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 
    return self.dresserImages.count; 
} 


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ 
    static NSString *identifier = @"Cell"; 

    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; 

    UIImageView *dresserImageView = (UIImageView *)[cell viewWithTag:100]; 
    dresserImageView.image = [UIImage imageNamed:[[self.dresserImages objectAtIndex:indexPath.row] objectForKey:@"image"]]; 

    return cell; 
} 

- (void)scrollViewDidScroll:(UIScrollView *)scrollView { 
    if (_startingIndexPath) { 
     NSInteger currentIndex = floor((scrollView.contentOffset.x - scrollView.bounds.size.width/1)/scrollView.bounds.size.width) + 1; 
     if (currentIndex < [self.dresserImages count]) { 
      self.title = self.dresserImages[currentIndex][@"name"]; 
     } 
    } 
} 

- (BOOL) shouldAutorotate 
{ 
    return YES; 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 

    UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout; 
    layout.itemSize = self.view.bounds.size; 

    [self.collectionView scrollToItemAtIndexPath:self.startingIndexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 
+2

Вы установили идентификатор на обеих раскадровки? – Fogmeister

+0

Да, вы должны предоставить коды, особенно 'prepareForSegues: sender:' part – Raptor

+0

Вы должны установить идентификатор segue для раскадровки iPad отдельно, если вы r приложение является универсальным приложением –

ответ

0

Просто видел, что вы сказали "не появляется в IPad раскадровки".

Он будет отображаться не только без его настройки.

Вам нужно будет войти в файл раскадровки iPad и снова установить идентификатор segue.

+0

Любые конкретные причины для голосования? – Fogmeister

0

Если вы используете ту же раскадровку, что и iPhone с iPad, то вы можете просто скопировать содержимое раскадровки iPhone и вставить ее в раскадровку iPad. Вещи были бы неуместными, но при использовании автоматического макета он будет исправлен во время выполнения. Или вы могли бы следовать this

Смежные вопросы