本文整理汇总了C#中UIButton.RemoveFromSuperview方法的典型用法代码示例。如果您正苦于以下问题:C# UIButton.RemoveFromSuperview方法的具体用法?C# UIButton.RemoveFromSuperview怎么用?C# UIButton.RemoveFromSuperview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIButton
的用法示例。
在下文中一共展示了UIButton.RemoveFromSuperview方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
AnimateView animateView = new AnimateView();
//TODO: more info at: http://www.youtube.com/watch?v=6JePwHjVj6U
//MODAL PRESENTATION OF UIVIEW CONTROLLER--------------------------------------------------
//PRESENTATION STLYE IS FORM SHEET
btnTest.TouchUpInside += (object sender, EventArgs e) =>
{
AnimateModalViewController animateModalViewController = new AnimateModalViewController()
{
ModalTransitionStyle = UIModalTransitionStyle.CoverVertical,
ModalPresentationStyle = UIModalPresentationStyle.FormSheet,
};
this.NavigationController.PresentViewController(animateModalViewController,true,null);
};
//-----------------------------------------------------------------------------------------
//UIViewAnimation-----------------------------------------------------------------------------
//RECTANGLE ANIMATION (GO LEFT AND RETURN TO STARTING POINT
PointF p0;
UIView view = new UIView();
view.Frame = new RectangleF(20,20,200,200);
view.BackgroundColor = UIColor.Green;
this.View.Add(view);
btnCoreAnimation.TouchUpInside += (object sender, EventArgs e) =>
{
p0 = view.Center;
UIView.Animate(2,0,
UIViewAnimationOptions.CurveEaseInOut | UIViewAnimationOptions.Autoreverse,
() =>
{
view.Center =
new PointF(
UIScreen.MainScreen.Bounds.Right - view.Frame.Width /2,
view.Center.Y
);
},
() => { view.Center = p0;}
);
};
//UIView ANIMATION (FADE IN FROM THE CENTER OF THE SCREEN)---------------------------------------------
PointF p1;
UIView view1 = new UIView();
view1.Frame = new RectangleF(this.View.Center.X,this.View.Center.Y,0,0);
view1.BackgroundColor = UIColor.Gray;
//DISMISS BUTTON FOR VIEW1
UIButton btnDismissView1 = new UIButton(UIButtonType.RoundedRect);
btnDismissView1.Frame = new RectangleF(318,687,133,44);
btnDismissView1.Title(UIControlState.Normal);
btnDismissView1.SetTitle("Dismiss View1",UIControlState.Normal);
//DISMISS VIEW1
btnDismissView1.TouchUpInside += (object sender, EventArgs e) =>
{
UIView.Animate(2,0,UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseIn,
() =>
{
btnDismissView1.RemoveFromSuperview();
view1.Frame = new RectangleF(this.View.Center.X,this.View.Center.Y,0,0);
},
() =>{view1.RemoveFromSuperview();}
);
};
//ADD VIEW1 AS SUBVIEW TO this.View
btnFadeInView.TouchUpInside += (object sender, EventArgs e) =>
{
this.View.Add(view1);
p1 = view1.Center;
UIView.Animate(2,0,UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.CurveEaseIn,
() =>
{
view1.Frame = new RectangleF(0,0,768,960);
},
() => {view1.Add(btnDismissView1);} //EMPTY, COULD BE USED FOR ACTION UPON COMPLETITION OF ANIMATION
);
};
//---------------------------------------------------------------------------------------------
//iOS built-in animations----------------------------------------------------------------------
btnCrossDissolve.TouchUpInside += (object sender, EventArgs e) =>
{
this.NavigationController.PushControllerWithTransition(animateView,
UIViewAnimationOptions.TransitionCrossDissolve);
};
//.........这里部分代码省略.........
示例2: LoadView
public override void LoadView()
{
base.LoadView ();
if (!SetupCaptureSession ()) {
Console.WriteLine ("Scan function requires a camera - doesn't work in the iOS Simulator");
throw new NotSupportedException ("Unable to setup camera for QR scan");
}
scanButton = UIButton.FromType (UIButtonType.System);
scanButton.BackgroundColor = UIColor.White;
scanButton.Frame = new RectangleF(50,60,220,80);
scanButton.SetTitle ("Scan Again", UIControlState.Normal);
scanButton.TouchUpInside += (sender, e) => {
View.BackgroundColor = UIColor.Black;
session.StartRunning ();
qrResult1.Text = "";
qrResult2.Text = "";
scanButton.RemoveFromSuperview ();
};
qrResult1 = new UILabel(new RectangleF (10, 300, 300, 40));
qrResult1.TextColor = UIColor.White;
qrResult1.BackgroundColor = UIColor.Clear;
qrResult1.Font = UIFont.BoldSystemFontOfSize (32f);
qrResult1.AdjustsFontSizeToFitWidth = true;
qrResult2 = new UILabel(new RectangleF (10, 350, 300, 30));
qrResult2.TextColor = UIColor.White;
qrResult2.BackgroundColor = UIColor.Clear;
qrResult2.Font = UIFont.BoldSystemFontOfSize (18f);
QrScan += (result) => {
//Console.WriteLine ("Scan : " + result.BarcodeFormat + " " + result.Text );
InvokeOnMainThread (async () => {
session.StopRunning();
qrResult2.Text = result; //.Text;
var scan = new ConfScan () { Barcode=result, ScannedAt=DateTime.Now };
bool valid = false, reentry = false;
// LOCAL DATA OPERATIONS
// check for attendee
var validAttendee = AppDelegate.UserData.CheckBarcode (scan);
if (validAttendee != null) {
valid = true;
scan.IsValid = true;
qrResult1.Text = validAttendee.Name;
if (validAttendee.ScanCount > 0) {
reentry = true;
validAttendee.ScanCount += 1;
qrResult2.Text += " (re-entry)";
AppDelegate.UserData.Update (validAttendee);
} else {
// first entry
validAttendee.ScanCount = 1;
AppDelegate.UserData.Update (validAttendee);
}
} else {
qrResult1.Text = "BARCODE NOT FOUND";
scan.AttendeeName = "NOT FOUND";
scan.IsValid = false;
}
// Adds to local database
AppDelegate.UserData.AddScan (scan);
//HACK: commented out Azure for now ~ no account
// and still need to test the new async-style calls
// try {
// // REMOTE DATA OPERATIONS
// // Massive hack here, need to revisit how we deal with these Azure updates
// await AzureManager.scanTable.InsertAsync (scan);
// Console.WriteLine ("Updated scan in cloud, Id:" + scan.Id);
//
// // we need to find out of the Attendee.Barcode is already in Azure...
// if (validAttendee != null) {
// if (validAttendee.Id > 0) {
// await AzureManager.attendeeTable.UpdateAsync (validAttendee);
// Console.WriteLine ("Updated attendee in cloud, Id:" + validAttendee.Id);
// } else {
// await AzureManager.attendeeTable.InsertAsync (validAttendee);
// Console.WriteLine ("Inserted attendee in cloud, Id:" + validAttendee.Id);
// AppDelegate.UserData.Update (validAttendee); // with Azure~Id
// Console.WriteLine ("Inserted attendee in local, Id:" + validAttendee.Id);
// }
// }
// } catch (AggregateException ae) {
// Console.WriteLine ("AZURE error " + ae);
// } catch (Exception e) {
// Console.WriteLine ("AZURE error " + e);
// }
if (valid && !reentry) {
View.BackgroundColor = UIColor.Green;
Speak ("Please enter");
} else if (valid && reentry) {
View.BackgroundColor = UIColor.Orange;
//.........这里部分代码省略.........
示例3: PlaceLightButton
private void PlaceLightButton()
{
// Add or move the light button overlay
_lightButton = _lightButton ?? BuildLightButton();
if(_lightButton.Superview != null)
{
_lightButton.RemoveFromSuperview();
}
// Flipping from list view can "dirty" this value, so choose it by orientation explicitly instead
var bounds = Util.IsLandscape() ? new RectangleF(0, 0, 480, 320 - 20) : new RectangleF(0, 0, 320, 480 - 20);
_lightButton.Frame = new RectangleF(
bounds.Width - _lightButton.Bounds.Width,
bounds.Height - _lightButton.Bounds.Height,
_lightButton.Bounds.Width,
_lightButton.Bounds.Height
);
View.AddSubview(_lightButton);
}
示例4: HandleScanResult
void HandleScanResult(ZXing.Result result)
{
string msg = "";
if (result != null && !string.IsNullOrEmpty (result.Text)) {
msg = "Found Barcode: " + result.Text;
UIImage captureImage = result.CaptureImage as UIImage;
if (captureImage != null) {
InvokeOnMainThread (() => {
nfloat height = 300 * (captureImage.Size.Height / captureImage.Size.Width);
CGRect theRect = new CGRect(new CGPoint(10,0), new CGSize(300,height));
UIImageView theView = new UIImageView(theRect);
theView.ContentMode = UIViewContentMode.ScaleToFill;
this.View.AddSubview(theView);
UIGraphics.BeginImageContext(captureImage.Size);
captureImage.Draw(CGPoint.Empty);
CGContext ctx = UIGraphics.GetCurrentContext();
ctx.SetStrokeColor(UIColor.Red.CGColor);
ctx.SetLineWidth(2);
ctx.MoveTo(result.ResultPoints[0].X, result.ResultPoints[0].Y);
ctx.AddLineToPoint(result.ResultPoints[1].X, result.ResultPoints[1].Y);
ctx.StrokePath();
ctx.SetStrokeColor(UIColor.Green.CGColor);
ctx.MoveTo(result.ResultPoints[1].X, result.ResultPoints[1].Y);
ctx.AddLineToPoint(result.ResultPoints[2].X, result.ResultPoints[2].Y);
ctx.StrokePath();
ctx.SetStrokeColor(UIColor.Blue.CGColor);
ctx.MoveTo(result.ResultPoints[2].X, result.ResultPoints[2].Y);
ctx.AddLineToPoint(result.ResultPoints[3].X, result.ResultPoints[3].Y);
ctx.StrokePath();
ctx.SetStrokeColor(UIColor.Yellow.CGColor);
ctx.MoveTo(result.ResultPoints[3].X, result.ResultPoints[3].Y);
ctx.AddLineToPoint(result.ResultPoints[0].X, result.ResultPoints[0].Y);
ctx.StrokePath();
UIImage retImage = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
theView.Image = retImage;
UIButton theBtn = new UIButton(new CGRect(100,380,100,32));
theBtn.SetTitle("Dismiss", UIControlState.Normal);
theBtn.BackgroundColor = UIColor.Red;
this.View.AddSubview(theBtn);
theBtn.TouchUpInside += (object sender, EventArgs e) => {
theView.RemoveFromSuperview();
theBtn.RemoveFromSuperview();
};
});
}
}
else
msg = "Scanning Canceled!";
this.InvokeOnMainThread(() => {
var av = new UIAlertView("Barcode Result", msg, null, "OK", null);
av.Show();
});
}
示例5: LoadView
public override void LoadView()
{
base.LoadView ();
if (!SetupCaptureSession ())
throw new NotSupportedException ("Unable to setup camera for QR scan");
scanButton = UIButton.FromType (UIButtonType.RoundedRect);
scanButton.Frame = new RectangleF(50,60,220,80);
scanButton.SetTitle ("Scan Again", UIControlState.Normal);
scanButton.TouchUpInside += (sender, e) => {
View.BackgroundColor = UIColor.Black;
session.StartRunning ();
qrResult1.Text = "";
qrResult2.Text = "";
scanButton.RemoveFromSuperview ();
};
qrResult1 = new UILabel(new RectangleF (10, 300, 300, 40));
qrResult1.TextColor = UIColor.White;
qrResult1.BackgroundColor = UIColor.Clear;
qrResult1.Font = UIFont.BoldSystemFontOfSize (32f);
qrResult1.AdjustsFontSizeToFitWidth = true;
qrResult2 = new UILabel(new RectangleF (10, 350, 300, 30));
qrResult2.TextColor = UIColor.White;
qrResult2.BackgroundColor = UIColor.Clear;
qrResult2.Font = UIFont.BoldSystemFontOfSize (18f);
previewLayer.Frame = new System.Drawing.RectangleF (0, 0, 320, 290);
View.Layer.AddSublayer (previewLayer);
QrScan += (result) => {
Console.WriteLine ("Scan : " + result.BarcodeFormat + " " + result.Text );
InvokeOnMainThread (() => {
qrResult2.Text = result.Text;
var scan = new ConfScan () { Barcode=result.Text, ScannedAt=DateTime.Now };
bool valid = false, reentry = false;
// LOCAL DATA OPERATIONS
// check for attendee
var validAttendee = AppDelegate.UserData.CheckBarcode (scan);
if (validAttendee != null) {
valid = true;
scan.IsValid = true;
qrResult1.Text = validAttendee.Name;
if (validAttendee.ScanCount > 0) {
reentry = true;
validAttendee.ScanCount += 1;
qrResult2.Text += " (re-entry)";
AppDelegate.UserData.Update (validAttendee);
} else {
// first entry
validAttendee.ScanCount = 1;
AppDelegate.UserData.Update (validAttendee);
}
} else {
qrResult1.Text = "BARCODE NOT FOUND";
scan.AttendeeName = "NOT FOUND";
scan.IsValid = false;
}
AppDelegate.UserData.AddScan (scan);
// REMOTE DATA OPERATIONS
// Massive hack here, need to revisit how we deal with PKs in Azure
AzureManager.scanTable.InsertAsync (scan)
.ContinueWith (t => {
Console.WriteLine ("Updated scan in cloud " + t.Status + " " + t.Id);
}, scheduler);
// we need to find out of the Attendee.Barcode is already in Azure...
if (validAttendee != null) {
if (validAttendee.Id > 0)
AzureManager.attendeeTable.UpdateAsync (validAttendee)
.ContinueWith (u => {
Console.WriteLine ("Updated attendee in cloud " + u.Status + " update " + u.Id);
}, scheduler);
else {
AzureManager.attendeeTable.InsertAsync (validAttendee)
.ContinueWith (v => {
Console.WriteLine ("Inserted attendee in cloud " + v.Status + " " + v.Id + " ~ " + validAttendee.Id);
AppDelegate.UserData.Update (validAttendee); // with Azure~Id
}, scheduler);
}
}
if (valid && !reentry)
View.BackgroundColor = UIColor.Green;
else if (valid && reentry)
View.BackgroundColor = UIColor.Orange;
else
View.BackgroundColor = UIColor.Red;
session.StopRunning ();
View.AddSubview (scanButton);
});
};
//.........这里部分代码省略.........