Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios iPad情节串连板上的序列标识符_Ios_Ipad_Storyboard_Uistoryboardsegue - Fatal编程技术网

Ios iPad情节串连板上的序列标识符

Ios iPad情节串连板上的序列标识符,ios,ipad,storyboard,uistoryboardsegue,Ios,Ipad,Storyboard,Uistoryboardsegue,我有一个应用程序设置了集合视图,其中一个有一系列单元格,然后切换到另一个全屏单元格,以重新创建一个照片库。我在iPhone上可以很好地实现这一点,但当我在iPad上尝试时,点击第一个单元格应该可以识别索引路径上的项目,并将其传递到全屏视图,而这并没有发生 我相信原因是我正在寻找一个segue标识符,因为这是一个通用的应用程序,我在两种用途中使用相同的代码。在iPhone故事板上,我可以设置segue标识符,但这不会出现在iPad故事板上。问题是…。这正常吗?有办法解决吗?我可以根据要求提供代码,

我有一个应用程序设置了集合视图,其中一个有一系列单元格,然后切换到另一个全屏单元格,以重新创建一个照片库。我在iPhone上可以很好地实现这一点,但当我在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 Study3CollectionViewController
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
}
回归自我;
}
-(无效)viewDidLoad{
[超级视图下载];
[自创数据];
}
-(void)创建数据{
self.dresserImages=[NSMutableArray];
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@"IMG_4723.JPG,"image,nil]];;
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@"IMG_4726.JPG,"image,nil]];;
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@"IMG_4729.JPG,"image,nil]];;
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@"IMG_4730.JPG,"image,nil]];;
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@"IMG_4731.JPG,"image,nil]];;
[self.collectionView-reloadData];
}
-(NSInteger)collectionView:(UICollectionView*)collectionView项目编号截面:(NSInteger)截面{
返回self.dresserImages.count;
}
-(UICollectionViewCell*)collectionView:(UICollectionView*)collectionView cellForItemAtIndexPath:(NSIndexPath*)indexPath{
静态NSString*标识符=@“单元格”;
UICollectionViewCell*cell=[collectionView dequeueReusableCellWithReuseIdentifier:indexPath的标识符:indexPath];
UIImageView*dresserImageView=(UIImageView*)[带标记的单元格视图:100];
dresserImageView.image=[UIImage ImageName:[[self.dresserImages objectAtIndex:indexath.row]objectForKey:@“image”];
返回单元;
}
-(无效)scrollViewDidScroll:(UIScrollView*)scrollView{
if(_startingIndexPath){
NSInteger currentIndex=floor((scrollView.contentOffset.x-scrollView.bounds.size.width/1)/scrollView.bounds.size.width)+1;
如果(当前索引<[self.dresserImages count]){
self.title=self.dresserImages[currentIndex][@“name”];
}
}
}
-(void)prepareForSegue:(UIStoryboardSegue*)segue发送方:(id)发送方{
if([segue.identifier IsequalString:@“collectionView”])
{
Study3DetailCollectionViewController*destViewController=(Study3DetailCollectionViewController*)segue.destinationViewController;
NSIndexPath*indexPath=[[self.collectionView indexPathsForSelectedItems]对象索引:0];
destViewController.startingIndexPath=indexPath;
[destViewController.collectionView ScrollToItemAtScrollPosition:UICollectionViewScrollPositionCenter水平动画:否];
[self.collectionView取消ItemAtIndexPath:indexPath:否];
}
}
-(无效)视图将显示:(BOOL)动画{
[超级视图将显示:动画];
[self.collectionView scrollToItemAtIndexPath:self.StartingIndepath atScrollPosition:UICollectionView ScrollPositionCenter水平动画:否];
}
-(无效)未收到记忆警告
{
[超级记忆警告];
//处置所有可以重新创建的资源。
}
@结束
详细视图

@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
@implementation Study3DetailCollectionViewController
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
}
回归自我;
}
-(无效)viewDidLoad{
[超级视图下载];
[自创数据];
}
-(void)创建数据{
self.dresserImages=[NSMutableArray];
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@"IMG_4723.JPG,"image,nil]];;
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@"IMG_4726.JPG,"image,nil]];;
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@"IMG_4729.JPG,"image,nil]];;
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@"IMG_4730.JPG,"image,nil]];;
[self.dresserImages addObject:[[NSMutableDictionary alloc]
initWithObjectsAndKeys:@“牛顿衣柜”@“姓名”,
@“IMG_47