View使用tabbar和导航控制器忽略了错误的视图

时间:2013-09-27 15:08:21

标签: iphone ios objective-c uinavigationcontroller

好的,这是我的基本设置storyboard

的图片

现在这可能不是设置这一切的最佳方式,但我凭借我必须获得想要效果的知识尽我所能。现在我的问题出现在视图1中,但只有在您执行此操作时才会发生:从菜单单击视图2,3或4开始转到该视图然后使用标签栏按钮转到查看1现在在此屏幕上您将单击获取在其viewcontroller中具有以下代码的图片按钮,用于显示图像选择器。现在出现的问题是,如果你回到这一点,它会将你带到你从菜单中点击的tabbarview,无论是2,3还是4.如果你从菜单中点击了视图1,它会很好。

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.
    self.selectedPhotos = [NSMutableArray array];

    __block AGViewController *blockSelf = self;

    ipc = [[AGImagePickerController alloc] initWithDelegate:self];
    ipc.didFailBlock = ^(NSError *error) {
        NSLog(@"Fail. Error: %@", error);

        if (error == nil) {
            [blockSelf.selectedPhotos removeAllObjects];
            NSLog(@"User has cancelled.");

          [blockSelf dismissViewControllerAnimated:YES completion:nil];


        } else {

            // We need to wait for the view controller to appear first.
            double delayInSeconds = 0.5;
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
                [blockSelf dismissViewControllerAnimated:YES completion:nil];
            });
        }

        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];

    };
    ipc.didFinishBlock = ^(NSArray *info) {
        [blockSelf.selectedPhotos setArray:info];

        NSLog(@"Info: %@", info);

        //add all selected photos to the claim

        [blockSelf setClaimPhotos:info];

        [blockSelf dismissViewControllerAnimated:YES completion:nil];

        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:YES];
    };

}

- (void)openAction:(id)sender
{    
    // Show saved photos on top
    ipc.shouldShowSavedPhotosOnTop = NO;
    ipc.shouldChangeStatusBarStyle = YES;
    ipc.selection = self.selectedPhotos;
    ipc.maximumNumberOfPhotosToBeSelected = 5;

    // Custom toolbar items
    AGIPCToolbarItem *selectAll = [[AGIPCToolbarItem alloc] initWithBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"+ Select All" style:UIBarButtonItemStyleBordered target:nil action:nil] andSelectionBlock:^BOOL(NSUInteger index, ALAsset *asset) {
        return YES;
    }];
    AGIPCToolbarItem *flexible = [[AGIPCToolbarItem alloc] initWithBarButtonItem:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] andSelectionBlock:nil]; 

    AGIPCToolbarItem *deselectAll = [[AGIPCToolbarItem alloc] initWithBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"- Deselect All" style:UIBarButtonItemStyleBordered target:nil action:nil] andSelectionBlock:^BOOL(NSUInteger index, ALAsset *asset) {
        return NO;
    }];  
    ipc.toolbarItemsForManagingTheSelection = @[selectAll, flexible, flexible, deselectAll];

    [self presentViewController:ipc animated:YES completion:nil];
}

(开放动作与vc上的按钮相关联)

我真的需要这方面的帮助,因为我整个星期一直坚持这个问题并且一直在尝试所有类型的解决视图控制器等。

1 个答案:

答案 0 :(得分:1)

问题是由于TabBarController上的自定义类导致SelectedIndex属性出现意外行为。