0

我有 UIScrollView 它有下一个按钮单击它运行此代码

-(IBAction)ScrollPage:(id)sender {

        NSLog(@"ScrollPage Called");
        NSInteger positionX;
        if ([sender tag] == 1) {
            positionX = AddNewScroll.contentOffset.x - 320;
        }else {
            positionX = AddNewScroll.contentOffset.x + 320;
        }
        [AddNewScroll setContentOffset:CGPointMake(positionX,0) animated:YES];

    }

它会将滚动移动到新页面,然后我有按钮点击它会调用

-(IBAction)SelectImg:(id)sender {

    UIActionSheet *imgMenu = [[UIActionSheet alloc] initWithTitle:@"choose image"
                                                         delegate:self
                                                cancelButtonTitle:@"Cancel"
                                           destructiveButtonTitle:@"Camera"
                                                otherButtonTitles:@"Album",nil];
    imgMenu.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    [imgMenu showInView:[UIApplication sharedApplication].keyWindow];

}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

    imgPicker = [[UIImagePickerController alloc] init];
    imgPicker.allowsEditing = YES;
    imgPicker.delegate = self;


    @try {
        if (buttonIndex == 0) {
            imgPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
            [self presentModalViewController:imgPicker animated:YES];
        }

        if (buttonIndex == 1) {
            imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

            //Start iPhone PhotoLibrary
            if ([[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
                [self presentModalViewController:imgPicker animated:YES];

            } else
            //Start iPad  PhotoLibrary
            if ([[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPad){
                aPopover = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
                [aPopover presentPopoverFromRect:CGRectMake(250, 40, 300, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

            }
        }
    }

问题是当它调用 actionSheet 时 UIScrollView 本身转到第一页 contentOffset 为 0 然后调用 scrollViewDidScroll

附言。分页禁用

4

1 回答 1

0

在方法clickedButtonAtIndex中,您正在重新分配 UIImagePickerController。这不就是它回到0的原因吗?

AddNewScroll另外,和之间有什么关系imgPicker

于 2013-03-31T07:56:28.273 回答