Sunday, 15 May 2011

iphone - uitableview numberOfRowsInSection count -


This is more of a math problem than anything else. I have a dynamic array object in which I store user photos.

  Arriveda = [[NSARLAAO] Initvith Objects: @ "Pica 1 page", @ "Pick 2 page", @ "Pixel page", @ "Pixel page", @ "Pixie 5.png ", @" Pic6.png ", @" pic7.png ", @" pic8.png ", zero];   

In this array, how many objects can it be in eg 8 or 20 or 100. In my table view I have created 4 UIImageViews in each row by adding them to cell contentview. So if we say

  • If Arithidata has 3 objects then I want UITTable to make 1 row
  • If there are 4 objects in arredity, then I make 1 row Want uitabal for
  • If there are 5 objects in Arredata, then I want UIT to create 2 rows
  • If the array has 8 objects then I want to create a 2 line
  • If there are 10 objects in Arredata, I want UITT to create 3 lines
  • .... and so on

    So how will I do this in my ari data? Numbers for objects?

      - (NSInteger) table view: (UITableView *) table view numberoffersinsense section: (NSInteger) section {// NSLog (@ "Inside numberOfRowsInSection"); // Return [saw data count]; // Can not think of an argument to use here?   

    Picture is equal to one thousand words I

     Enter the image details

    So basically you need to split all four, frameworks Above the objective-C, there is an integer division (round of zero), you can do this by doing this:

      - (NSInteger) Table view: (UITableView *) table view numberofrox ins: (NSInteger) section {Return (Arry Data Coat + 3) / 4; }   

    In general, to create rounded integers (with positive integers), you add the decimal before dividing.

    If you have defined the number of images per line continuously, use it for example:

      static const int kImagesPerRow = 4; - (NSInteger) Table view: (UITableView *) table view numberofrease ins: (NSInteger) section {return (arry Data.count + kImagesPerRow - 1) / kImagesPerRow; }    

No comments:

Post a Comment