[MonoTouch] Subview not displaying
ric3kg
rickgross at mac.com
Tue Mar 20 19:03:38 UTC 2012
I'm drawing a set of tabs. This first "Day" gets the proper background
imageView inserted in the dayTab view. But the next tab, Week, gets nothing,
it has a clear background (see attached). I can't see why that is... The
graphics are all on the device, I know that because switching tabs loads the
proper background into the Day tab.
Code:
//Day Tab
dayTab = new UIView(dayActiveRect);
dayTab.Layer.CornerRadius = 10f;
dayTab.Layer.BorderColor = UIColor.Black.CGColor;
dayTab.Layer.BorderWidth = .5f;
dayTab.Layer.MasksToBounds = true;
UITapGestureRecognizer dayTap = new UITapGestureRecognizer();
dayTap.AddTarget(this, new Selector("DayTap"));
dayTab.AddGestureRecognizer(dayTap);
//Add the background
ivDayBack = new UIImageView(dayActiveRect);
ivDayBack.Image = appDelegate.store.GetArt("btn102-110Normal.png");
ivDayBack.Tag = 1;
dayTab.AddSubview(ivDayBack);
//Set the Day text
dayLabelRect = new RectangleF(0f, 60f, 100f, 18f);
lblDay = new UILabel(labelRect);
lblDay.Text = "Day"; //Localize
lblDay.TextAlignment = UITextAlignment.Center;
lblDay.TextColor = UIColor.Black;
lblDay.Font = UIFont.FromName(Utilities.fontBold, 18f);
lblDay.BackgroundColor = UIColor.Clear;
//Set the image
dayImageView = new RectangleF(20f, 10f, 60f, 40f);
ivDay = new UIImageView(imageRect);
ivDay.Image = appDelegate.store.GetArt("dayIcon.png");
dayTab.AddSubview(lblDay);
dayTab.AddSubview(ivDay);
this.AddSubview(dayTab);
//Week Tab
weekTab = new UIView(weekInactiveRect);
weekTab.Layer.CornerRadius = 10f;
weekTab.Layer.BorderColor = UIColor.Black.CGColor;
weekTab.Layer.BorderWidth = .5f;
weekTab.Layer.MasksToBounds = true;
UITapGestureRecognizer weekTap = new UITapGestureRecognizer();
weekTap.AddTarget(this, new Selector("WeekTap"));
weekTab.AddGestureRecognizer(weekTap);
//Set the background image
ivWeekBack = new UIImageView(weekInactiveRect);
ivWeekBack.Image = appDelegate.store.GetArt("btn102-110Disabled.png");
ivWeekBack.Tag = 200;
weekTab.AddSubview(ivWeekBack);
//Set the Week text
weekLabelRect = new RectangleF(100f, 60f, 100f, 18f);
lblWeek = new UILabel(labelRect);
lblWeek.Text = "Week"; //Localize
lblWeek.TextAlignment = UITextAlignment.Center;
lblWeek.TextColor = UIColor.Black;
lblWeek.Font = UIFont.FromName(Utilities.fontBold, 18f);
lblWeek.BackgroundColor = UIColor.Clear;
//Set the image
weekImageView = new RectangleF(120f, 10f, 60f, 40f);
ivWeek = new UIImageView(imageRect);
ivWeek.Image = appDelegate.store.GetArt("weekIcon.png");
weekTab.AddSubview(lblWeek);
weekTab.AddSubview(ivWeek);
this.AddSubview(weekTab);
http://monotouch.2284126.n4.nabble.com/file/n4489997/Tabs.png
Thanks,
Rick
--
View this message in context: http://monotouch.2284126.n4.nabble.com/Subview-not-displaying-tp4489997p4489997.html
Sent from the MonoTouch mailing list archive at Nabble.com.
More information about the MonoTouch
mailing list