public override void ViewDidLoad() { base.ViewDidLoad(); // UIButton button_pinterest = new UIButton(UIButtonType.RoundedRect) // { // Frame = new System.Drawing.RectangleF( 60, 100, 200, 80) // , BackgroundColor = UIColor.White // }; // // // Perform any additional setup after loading the view, typically from a nib. // PinIt pin_it = new PinIt(); // PinIt.PinItButton = button_pinterest; // // View.AddSubview // ( // //button_pinterest // PinIt.PinItButton // ); // Perform any additional setup after loading the view, typically from a nib. View.BackgroundColor = UIColor.White; Title = "Pmterest Pint It Demo"; // Initialize a Pinterest instance with our client_id pinterest = new Com.Pinterest.Pinit.Pinterest("1234", "prod"); // Setup a sample imageview for the image we want to pin var sampleImage = UIImage.LoadFromData( NSData.FromUrl( NSUrl.FromString("http://placekitten.com/500/400") ) ); sampleImageView = new UIImageView(sampleImage) { Frame = new RectangleF(0, 61, kSampleImageWidth, kSampleImageHeight) }; View.AddSubview(sampleImageView); // Setup PinIt Button pinItButton = Com.Pinterest.Pinit.Pinterest.GetPinItButton(); pinItButton.Frame = new RectangleF(124, 281, 72, 32); // Add button handler pinItButton.TouchUpInside += pinItButton_HandleTouchUpInside; //(sender, e) => {}; View.AddSubview(pinItButton); return; }
public override void ViewDidLoad() { base.ViewDidLoad(); // UIButton button_pinterest = new UIButton(UIButtonType.RoundedRect) // { // Frame = new System.Drawing.RectangleF( 60, 100, 200, 80) // , BackgroundColor = UIColor.White // }; // // // Perform any additional setup after loading the view, typically from a nib. // PinIt pin_it = new PinIt(); // PinIt.PinItButton = button_pinterest; // // View.AddSubview // ( // //button_pinterest // PinIt.PinItButton // ); this.View.BackgroundColor = UIColor.White; RectangleF rect_label = new RectangleF(0, 0, 0, 0); UILabel titleLabel = new UILabel(rect_label); // CGFloat centerX = CGRectGetMidX(self.view.frame); float centerX = this.View.Bounds.GetMidX(); titleLabel.Text = @"Pinterest Pin It Demo"; titleLabel.BackgroundColor = UIColor.Clear; titleLabel.SizeToFit(); titleLabel.Frame = // CGRectMake new RectangleF ( //centerX - CGRectGetWidth(titleLabel.frame)/2 centerX - (float)(titleLabel.Frame.Width / 2.0) , kMargin //, CGRectGetWidth(titleLabel.frame) , titleLabel.Frame.Width // , CGRectGetHeight(titleLabel.frame) , titleLabel.Frame.Height ); this.View.AddSubview(titleLabel); // Setup a sample imageview for the image we want to pin NSUrl aURL = new NSUrl(@"http://placekitten.com/500/400"); NSData data = NSData.FromUrl(aURL); UIImage sampleImage = new UIImage(data); UIImageView sampleImageView = new UIImageView(new RectangleF(0, 0, 0, 0)); sampleImageView.Image = sampleImage; sampleImageView.Frame = //:CGRectMake new RectangleF ( centerX - (float)(kSampleImageWidth / 2) //, tCGRectGetMaxY(titleLabel.frame) + kMargin , titleLabel.Frame.GetMaxY() + kMargin , kSampleImageWidth , kSampleImageHeight ); this.View.AddSubview(sampleImageView); // Setup PinIt Button UIButton pinItButton = Com.Pinterest.Pinit.Pinterest.GetPinItButton(); // pinItButton is null!?!?!/ pinItButton.Frame = new RectangleF ( (float)(centerX - kPinItButtonWidth / 2) //, CGRectGetMaxY(sampleImageView.frame) + kMargin, , sampleImageView.Frame.GetMaxY() + kMargin , kPinItButtonWidth , kPinItButtonHeight ); //[pinItButton addTarget:self // action:@selector(pinIt:) // forControlEvents:UIControlEventTouchUpInside //]; //------------------------------------------------------------------------- //pinItButton.AddTarget // ( // this // , new MonoTouch.ObjCRuntime.Selector("PinIt") // , UIControlEvent.TouchUpInside // ); //------------------------------------------------------------------------- _pinterest = new Com.Pinterest.Pinit.Pinterest(client_id, "prod"); //_pinterest = new PinterestSDK.PinterestBinding(client_id); //_pinterest = new PinterestSDK.PinterestBinding(); pinItButton.TouchUpInside += PinItButton_HandleTouchUpInside; pinItButton.SetTitle("Press", UIControlState.Normal); pinItButton.BackgroundColor = UIColor.Blue; this.View.AddSubview(pinItButton); return; }