2013-03-30 2 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

пс. Пейджинг Отключено

ответ

0

В методе clickedButtonAtIndex вы перераспределяете свой UIImagePickerController. Разве это не причина, по которой она возвращается к 0?

Кроме того, какое отношение существует между AddNewScroll и imgPicker?

+0

кнопка на AddNewScroll, вызывающая ImgPicker, делает ее scrollview равным 0 – BoSoud

Смежные вопросы