iphone - ViewController 的 NSMutableArray

标签 iphone ios uiviewcontroller nsmutablearray

我正在思考如何创建一个 NSMutableArray 的 View Controller 。

然后一旦我有了那个数组,我怎么能在检测左右 UIgesture 滑动的方法中使用它来动画进出 View ...

这是获取我的手势的方法,它只是在两个 View 之间设置动画,但是我想在 View Controller 数组中的尽可能多的 View 之间设置动画。

- (void)swipedScreen:(UISwipeGestureRecognizer*)gesture {
    //Left swipe
    if (gesture.direction == UISwipeGestureRecognizerDirectionLeft) {

        [UIView animateWithDuration:0.25 animations:^{
            [self.detailViewB.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
            [self.detailViewA.view setFrame:CGRectMake(-320, 0, self.view.frame.size.width, self.view.frame.size.height)];
    }];

    }
    //Right swipe
    else if (gesture.direction == UISwipeGestureRecognizerDirectionRight){

        [UIView animateWithDuration:0.25 animations:^{
            [self.detailViewA.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
            [self.detailViewB.view setFrame:CGRectMake(320, 0, self.view.frame.size.width, self.view.frame.size.height)];
        }];

    }
}

另一方面,我有一个主视图 Controller ,我正在将这些 View Controller 加载到 subview 中......好吧至少那是计划......我目前正在使用 View ......

http://dl.dropbox.com/u/53813770/SMPrototypeB.zip

更新:

这是一张图片,向你们展示了我正在努力实现的目标。

enter image description here

这是从数组加载 View 的代码。谢天谢地,真痛苦。

DetailViewController *DVCA = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];
DetailViewControllerB *DVCB = [[DetailViewControllerB alloc] initWithNibName:@"DetailViewControllerB" bundle:[NSBundle mainBundle]];
DetailViewControllerC *DVCC = [[DetailViewControllerC alloc] initWithNibName:@"DetailViewControllerC" bundle:[NSBundle mainBundle]];

//Create Array of views
viewArray = [NSArray arrayWithObjects:DVCA, DVCB, DVCC, nil];



// set detail View as first view 
UIViewController *recordController = [viewArray objectAtIndex:0];
// This was the bit causing me so many issues.
[self.view addSubview:recordController.view];

最佳答案

查看您的项目并发现您的 Root View Controller 实际上是一个导航 Controller ,我将重新发布作为答案。

如果您的初始 View Controller 是一个导航 Controller ,那么操作系统会为您提供您正在寻找的数组,它是 UINavigationController 上的 viewControllers 属性。这是不可变的,但您可以制作它的可变副本。

关于iphone - ViewController 的 NSMutableArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10825853/

相关文章:

iphone - 像在 iBooks 中一样创建可编辑的 GridView

ios - 使用 swift 将图像按原样保存在相册中

ios - UIView 职责(面向对象编程)

iphone - self.delegate = self;这样做有什么问题吗?

iphone - 使用默认方法删除 uitableview 行时遇到问题

ios - 如何同步背景音乐和按钮?

ios - 协议(protocol)的 Swift 实例

ios - 为什么 UIPageViewController 在翻页后调整其 UIViewControllers View 的大小?

iphone - testflight 未检测到此应用的应用 token

iphone - 访问 UIImagePickerController 拍摄的图像的元数据(exif 标签)- iOS/iPhone