【问题标题】:iOS: how to change between views after picking a photos?iOS:挑选照片后如何在视图之间切换?
【发布时间】:2023-03-03 02:09:01
【问题描述】:

我正在编写一个应用程序,用户可以在库中选择一张照片,发送到服务器。 这是我的代码

-(IBAction)btnTakePictureClicked { UIImagePickerController* 选择器 = [[UIImagePickerController alloc] init]; 选择器.delegate=自己; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentModalViewController:picker animated:YES]; [选择器发布]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{ [picker.parentViewControllerdismissModalViewControllerAnimated:YES]; self.imgTemp = 图像; // 这些行应该在哪里? Send* send = [[Send alloc] initWithNibName:@"Send Email" bundle:nil]; [self presentModalViewController:发送动画:YES]; [发送发布]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { [picker.parentViewControllerdismissModalViewControllerAnimated:YES]; }

我希望在挑选照片后,它会变为发送页面。但是,它还是回到了首页。

这些行应该在哪里?

Send* send = [[Send alloc] initWithNibName:@"Send Email" bundle:nil]; [self presentModalViewController:发送动画:YES]; [发送发布];

【问题讨论】:

    标签: iphone objective-c ios xcode


    【解决方案1】:

    如果你呈现一个带有动画的模态视图控制器,在完成的块中释放它,你可以尝试:

        Send* send = [[Send alloc] initWithNibName:@"Send Email" bundle:nil];
        [self presentViewController:send animated:YES completion:^{
            [send release];
        }];
    

    【讨论】:

      【解决方案2】:
      - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo{
          [picker.parentViewController dismissModalViewControllerAnimated:YES];
          self.imgTemp = image;
      .....
      

      在这里,您将“是”改为“否”。即,关闭没有动画的模态视图。

      【讨论】:

      • 对不起,Gomathi。这不是我要问的。
      【解决方案3】:

      一旦你选择了图像,它就会移动到发送视图控制器

      - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:UIImage *)image editingInfo:(NSDictionary *)editingInfo{
      self.imgTemp = image;
      Send* send = [[Send alloc] initWithNibName:@"Send Email" bundle:nil];
      [self presentModalViewController:send animated:YES];
      [send release];
      

      }

      【讨论】:

      • 它仍然返回到包含从库加载按钮的页面。无论如何,谢谢你的帮助。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-17
      • 2017-11-15
      • 2014-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多