1

好的,这是我的基本设置的图片 故事板

现在这可能不是设置它的最佳方式,但我尽我所能用我必须获得我想要的效果的知识。现在我的问题源于视图 1,但只有在您这样做时才会发生:从菜单开始单击视图 2,3 或 4 以转到该视图,然后使用选项卡栏按钮转到视图 1 现在在此屏幕上您将单击获取图片按钮在其视图控制器中具有以下代码以显示图像选择器。现在问题来了,如果您此时返回,它会将您带到您从菜单中单击的选项卡视图,无论是 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上的按钮相关联)

我真的需要帮助,因为我整个星期都被困在这个问题上,并且一直在尝试所有类型的关闭视图控制器等。

4

1 回答 1

1

问题是由于一个自定义类TabBarController导致了SelectedIndex属性的意外行为。

于 2013-09-30T16:35:21.543 回答