Hello. I am having some problems with pagecontrol and scrollview. I added these two controls onto my xib file in IB, created the outlets, wired them up. I wrote some code which is supposed to show images fetched from my sqlite database by randomly generating an image view and adding it as a subview to the scrollview. I am displaying this screen on touch event of a button. The images are being displayed just fine, I am also able to flip through them as expected. But the problem is my pagecontrol is simply not showing. The part where I placed it is simply appearing blank. [see the attached image for reference].
http://monotouch.2284126.n4.nabble.com/file/n4656425/pagectrl.png Here are some code blocks for the view controller. *************************************************************** private void CreatePanels() { int count=GlobalVariables.AssemblyImageCount; ScrollView.Scrolled+=ScrollViewScrolled; RectangleF scrollframe=ScrollView.Frame; scrollframe.Width=scrollframe.Width*count; ScrollView.ContentSize=scrollframe.Size; List<UIImage> imglst=new List<UIImage>(); imglst=objdbh.ReturnAssemblyImages (GlobalVariables.AssemblyID); for(int i=0; i<imglst.Count; i++) { UIImageView imgvw=new UIImageView(); RectangleF frame=ScrollView.Frame; imgvw.Image=imglst[i]; imgvw.SizeToFit (); PointF location=new PointF(); location.X=frame.Width*i; frame.Location=location; imgvw.Frame=frame; ScrollView.AddSubview (imgvw); } PageControl.Pages=count; PageControl.TouchUpInside+=HandlePageControlTouchUpInside; } *************************************************************** CODE FOR FETCHING COLLECTION OF IMAGES:::::: public List<UIImage> ReturnAssemblyImages(int assemblyid) { this.CreateDBConnection (); List<UIImage> imglist=new List<UIImage>(); try { string strimg="select Photo from Photo where PhotoOfflineID in (select PhotoID from AssemblyPhoto where AssemblyID="+assemblyid+")"; SqliteDataAdapter sda=new SqliteDataAdapter(strimg, sconn); DataSet ds=new DataSet(); sda.Fill (ds); byte[] mybuffer=null; for(int y=0; y<ds.Tables[0].Rows.Count; y++) { mybuffer=(byte[])(ds.Tables[0].Rows[y]["Photo"]); UIImage img= UIImage.LoadFromData (NSData.FromArray (mybuffer)); imglist.Add (img); } } catch(Exception exp) { throw exp; } this.CloseDBConnection (); return imglist.ToList (); } *************************************************************** private void ScrollViewScrolled(object sender, EventArgs e) { double page=Math.Floor ((ScrollView.ContentOffset.X-ScrollView.Frame.Width/2)/ScrollView.Frame.Width)+1; PageControl.CurrentPage=(int)page; } *************************************************************** public void HandlePageControlTouchUpInside(object sender, EventArgs e) { RectangleF Rect=new RectangleF(ScrollView.Frame.Width*PageControl.CurrentPage, ScrollView.Frame.Y, ScrollView.Frame.Width, ScrollView.Frame.Height); ScrollView.ScrollRectToVisible (Rect, true); } *************************************************************** Now I have some confusions. Firstly I am not sure whether to place the pagecontrol on the scrollview itself or simply on the view. Does it make a difference? I need some clarification on this. Also could it be that because I am generating the views based on results fetched from database it is interfering with the presentation of the pagecontrol? Please help me out by providing me with some guidance and steering me in the right direction. Look forward to receiving all the help on this matter from our ever helpful forum members. Many Thanks. -- View this message in context: http://monotouch.2284126.n4.nabble.com/Page-Control-Not-Showing-on-IPAD-View-tp4656425.html Sent from the MonoTouch mailing list archive at Nabble.com. _______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
