2013-03-30 135 views
0

我有UIScrollView中有一個按鈕,當點擊它運行這段代碼的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

PS。尋呼禁用

回答

0

在該方法中clickedButtonAtIndex,您要重新分配你的UIImagePickerController。這不就是它回到0的原因嗎?

此外,什麼關係也AddNewScrollimgPicker之間?

+0

AddNewScroll上的一個按鈕調用ImgPicker使其滾動視圖變爲0 – BoSoud