Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# CS1061错误Xamarin/Visual Studio_C#_Ios_Xamarin - Fatal编程技术网

C# CS1061错误Xamarin/Visual Studio

C# CS1061错误Xamarin/Visual Studio,c#,ios,xamarin,C#,Ios,Xamarin,我正在尝试运行我从中下载的一些源代码 这本质上是一个允许用户管理联系人和日历约会等的应用程序 我目前正在经历3个错误,所有这些似乎都是相关的 CS1061-UIImageView不包含“SetImage”的定义,并且找不到接受“UIImageView”类型的第一个参数的扩展方法“SetImage”(是否缺少using指令或程序集引用?) 似乎SetImage没有定义在什么地方? 有人能告诉我需要做什么来解决错误吗。我把我的代码贴在下面 using System; using Foundation

我正在尝试运行我从中下载的一些源代码

这本质上是一个允许用户管理联系人和日历约会等的应用程序

我目前正在经历3个错误,所有这些似乎都是相关的

CS1061-UIImageView不包含“SetImage”的定义,并且找不到接受“UIImageView”类型的第一个参数的扩展方法“SetImage”(是否缺少using指令或程序集引用?)

似乎SetImage没有定义在什么地方? 有人能告诉我需要做什么来解决错误吗。我把我的代码贴在下面

using System;
using Foundation;
using UIKit;
using System.CodeDom.Compiler;
using MessageUI;
using Microsoft.Office365.OutlookServices;
using FiveMinuteMeeting.Shared.ViewModels;
using CoreGraphics;
using FiveMinuteMeeting.Shared;


namespace FiveMinuteMeeting.iOS
{
  partial class ContactDetailViewController : UIViewController
  {
    public ContactDetailViewController(IntPtr handle)
  : base(handle)
{

}

public DetailsViewModel ViewModel
{
  get;
  set;
}


UIBarButtonItem save;
public override void ViewDidLoad()
{
   base.ViewDidLoad();

   NavigationController.NavigationBar.BarStyle = UIBarStyle.Black;

   save = new UIBarButtonItem(UIBarButtonSystemItem.Save,
    async (sender, args) =>
   {
     ViewModel.FirstName = TextFirst.Text.Trim();
     ViewModel.LastName = TextLast.Text.Trim();
     ViewModel.Email = TextEmail.Text.Trim();
     ViewModel.Phone = TextPhone.Text.Trim();
     //BigTed.BTProgressHUD.Show("Saving contact...");
     await ViewModel.SaveContact();
     //BigTed.BTProgressHUD.Dismiss();
     NavigationController.PopToRootViewController(true);
   });


   TextEmail.ShouldReturn += ShouldReturn;
   TextFirst.ShouldReturn += ShouldReturn;
   TextPhone.ShouldReturn += ShouldReturn;
   TextLast.ShouldReturn += ShouldReturn;

   TextEmail.ValueChanged += (sender, args) =>
     {
       ImagePhoto.SetImage(
      url: new NSUrl(Gravatar.GetURL(TextEmail.Text, 172)),
      placeholder: UIImage.FromBundle("missing.png")
      );
     };

   var color = new CGColor(17.0F / 255.0F, 113.0F / 255.0F, 197.0F / 255F);
   TextEmail.Layer.BorderColor = color;
   TextFirst.Layer.BorderColor = color;
   TextPhone.Layer.BorderColor = color;
   TextLast.Layer.BorderColor = color;


   ButtonCall.Clicked += (sender, args) => PlaceCall();

   NSNotificationCenter.DefaultCenter.AddObserver
    (UIKeyboard.DidShowNotification, KeyBoardUpNotification);

   // Keyboard Down
   NSNotificationCenter.DefaultCenter.AddObserver
   (UIKeyboard.WillHideNotification, KeyBoardDownNotification);

   double min = Math.Min((float)ImagePhoto.Frame.Width, (float)ImagePhoto.Frame.Height);
   ImagePhoto.Layer.CornerRadius = (float)(min / 2.0);
   ImagePhoto.Layer.MasksToBounds = false;
   ImagePhoto.Layer.BorderColor = new CGColor(1, 1, 1);
   ImagePhoto.Layer.BorderWidth = 3;
   ImagePhoto.ClipsToBounds = true;
}

public override void ViewWillAppear(bool animated)
{
  base.ViewWillAppear(animated);
  if (ViewModel == null)
  {
    ViewModel = new DetailsViewModel();
    NavigationItem.RightBarButtonItem = save;
  }
  else
  {
    this.Title = ViewModel.FirstName;
    TextEmail.Text = ViewModel.Email;
    TextFirst.Text = ViewModel.FirstName;
    TextLast.Text = ViewModel.LastName;
    TextPhone.Text = ViewModel.Phone;

    ImagePhoto.SetImage(
        url: new NSUrl(Gravatar.GetURL(ViewModel.Contact.EmailAddresses[0].Address, 172)),
        placeholder: UIImage.FromBundle("missing.png")
    );


    NavigationItem.RightBarButtonItem = null;
  }
}

private bool ShouldReturn(UITextField field)
{
  field.ResignFirstResponder();
  return true;
}

private void PlaceCall()
{
  var alertPrompt = new UIAlertView("Dial Number?",
      "Do you want to call " + TextPhone.Text + "?",
      null, "No", "Yes");

  alertPrompt.Dismissed += (sender, e) =>
  {
    if ((int)e.ButtonIndex >= (int)alertPrompt.FirstOtherButtonIndex)
    {

      var url = new NSUrl("tel:" + TextPhone.Text);
      if (!UIApplication.SharedApplication.OpenUrl(url))
      {
        var av = new UIAlertView("Not supported",
          "Scheme 'tel:' is not supported on this device",
          null,
          "OK",
          null);
        av.Show();
      }
      else
      {
        UIApplication.SharedApplication.OpenUrl(url);
      }
    }
  };

  alertPrompt.Show();
}


/*private async void SendEmail()
{
  var mailController = new MFMailComposeViewController();

  mailController.SetToRecipients(new string[] { TextEmail.Text });
  mailController.SetSubject("5 Minute Meeting");
  mailController.SetMessageBody("We are having a 5 minute stand up tomorrow at this time! Check your calendar.", false);

  mailController.Finished += (object s, MFComposeResultEventArgs args) =>
  {
    Console.WriteLine(args.Result.ToString());
    args.Controller.DismissViewController(true, (Action)null);
  };

  PresentViewControllerAsync(mailController, true);

}*/

public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender)
{
  switch(segue.Identifier)
  {
    case "email":
      {
        var vc = segue.DestinationViewController as SendEmailViewController;
        vc.ViewModel.FirstName = ViewModel.FirstName;
        vc.ViewModel.LastName = ViewModel.LastName;
        vc.ViewModel.Email = ViewModel.Email;
      }
      break;
    case "meeting":
      {
        var vc = segue.DestinationViewController as NewEventDurationViewController;
        vc.ViewModel.FirstName = ViewModel.FirstName;
        vc.ViewModel.LastName = ViewModel.LastName;
        vc.ViewModel.Email = ViewModel.Email;
      }
      break;
  }

}




#region Keyboard

private UIView activeview;             // Controller that activated the keyboard
private float scrollamount;    // amount to scroll 
private float bottom;           // bottom point
private const float Offset = 68.0f; // extra offset
private bool moveViewUp;           // which direction are we moving


private void KeyBoardDownNotification(NSNotification notification)
{
  if (moveViewUp) { ScrollTheView(false); }
}

private void ScrollTheView(bool move)
{

  // scroll the view up or down
  UIView.BeginAnimations(string.Empty, System.IntPtr.Zero);
  UIView.SetAnimationDuration(0.3);

  CGRect frame = (CGRect)View.Frame;

  if (move)
  {
    frame.Y -= scrollamount;
  }
  else
  {
    frame.Y += scrollamount;
    scrollamount = 0;
  }

  View.Frame = frame;
  UIView.CommitAnimations();
}

private void KeyBoardUpNotification(NSNotification notification)
{
  // get the keyboard size
  var r = (CGRect)UIKeyboard.FrameBeginFromNotification((NSNotification)notification);


  // Find what opened the keyboard
  foreach (UIView view in this.View.Subviews)
  {
    if (view.IsFirstResponder)
      activeview = view;
  }

  // Bottom of the controller = initial position + height + offset      
  bottom = ((float)activeview.Frame.Y + (float)activeview.Frame.Height + Offset);

  // Calculate how far we need to scroll
  scrollamount = ((float)r.Height - ((float)View.Frame.Size.Height - bottom));

  // Perform the scrolling
  if (scrollamount > 0)
  {
    moveViewUp = true;
    ScrollTheView(moveViewUp);
  }
  else
  {
    moveViewUp = false;
  }

}
#endregion

}
}
我对Xamarin&app development非常陌生,我只想运行它,因为它与我正在创建的项目非常相似


感谢您的帮助

这里是错误的解释

“好的,好的,好的” CS1061-UIImageView不包含“SetImage”的定义,并且找不到接受“UIImageView”类型的第一个参数的扩展方法“SetImage”(是否缺少using指令或程序集引用?)

在您的代码中,我没有看到ImagePhoto的声明检查右键单击转到定义。并验证imagePhoto是否存在我正在使用的方法setImage imagePhoto,该方法是UIImage类型的对象

   ImagePhoto.SetImage(
      url: new NSUrl(Gravatar.GetURL(TextEmail.Text, 172)),
      placeholder: UIImage.FromBundle("missing.png")
      );

下面是错误的解释

“好的,好的,好的” CS1061-UIImageView不包含“SetImage”的定义,并且找不到接受“UIImageView”类型的第一个参数的扩展方法“SetImage”(是否缺少using指令或程序集引用?)

在您的代码中,我没有看到ImagePhoto的声明检查右键单击转到定义。并验证imagePhoto是否存在我正在使用的方法setImage imagePhoto,该方法是UIImage类型的对象

   ImagePhoto.SetImage(
      url: new NSUrl(Gravatar.GetURL(TextEmail.Text, 172)),
      placeholder: UIImage.FromBundle("missing.png")
      );

SetImage
是包含在
Xamarin.SDWebImage
中的扩展方法。确保已还原所有nuget软件包或已通过

安装包Xamarin.SDWebImage


请参阅:

SetImage
是包含在
Xamarin.SDWebImage
中的扩展方法。确保已还原所有nuget软件包或已通过

安装包Xamarin.SDWebImage


请参阅:

谢谢,安装NuGet软件包解决了问题。请接受答案,这样问题就不会出现在未回答部分。谢谢谢谢,安装NuGet软件包解决了问题。请接受答案,这样问题就不会出现在未回答部分。谢谢