objective c - Justifying UIVIews on the iPhone: Algorithm Help -


I am moving in a way to align a collection of UIView subclasses within one view. I'm having a problem with the algorithm and was hoping someone can help me solve my errors. Here's a pseudocode where I am:

  // 1 See that How many items are int count = [item count]; // 2 shows how much white space has been omitted in the sarcastic view floatspace = [width]; [item total with]; // To apply additional left margin for items through 3 items, see [1] through objects [calculation -1] float margin = whites / (count-1); // 4 Understand the size of each sub container, if it is equally divided float sub-containerwidth = [width]] / calculation; // Apply the 5 margins, start with the second item for (ii = 1; i & lt; [Count of items]; i ++) {UIView * item = [Item ObjectExtends: i]; [Item setlift margin: (margin + i * sub-containerwidth]]; }  

Items do not appear evenly here. not even close. Where am i going

Here is a shot of this algorithm in verb:

EDIT: The code above is the codeodod. I have added the actual code here but if you are not familiar with the three 20 project then understand it Does not come in.

  @implementation TTTabStrip (Justified Bar Category) - (CGS ize) Layout Tabs {CGSize Size = [Super Layout Tabs]; CGPoint Content Offset = _scrollView.contentOffset; _scrollView.frame = self.bounds; _scrollView.contentSize = CGSizeMake (size.width + kTabMargin, self.height); CGFloat contentWidth = size.width + kTabMargin; If (contentWidth & lt; _scrollView.size.width) {// is to make the right argument / / how many items int count = [_tabViews count]; // 2 float flushpace = _scrollView.size.width - find contentWidth how much white space is left; // 3 To increase the margin on those items in some way it should be (white space) / count-1 float margin = white space / (count-1); // 4 start point float remove item wydath = (_scrollView.size.width-kTabMargin) / count; // Apply the margin for (int i = 1; i  

I was able to work it on my own! The issue I was applying margin for the elements is that I consider the origin and width of the previous elements and apply the margin.

  @implementation @tstabstrip (Justified Bar Category) - (CGS ize) Layout Tabs {CGSize Size = [Super Layout Tabs]; CGPoint Content Offset = _scrollView.contentOffset; _scrollView.frame = self.bounds; _scrollView.contentSize = CGSizeMake (size.width + kTabMargin, self.height); CGFloat contentWidth = size.width + kTabMargin; If (contentWidth & lt; _scrollView.size.width) {// is to make the right argument / / how many items int count = [_tabViews count]; // 2 float flushpace = _scrollView.size.width - find contentWidth how much white space is left; // 3 To increase the margin on those items in some way it should be (white space) / count-1 float margin = white space / (count-1); Apply Margin to // Margin (Ent I = 1; I & lt; [_tabViews count]; i ++) {/ 4} Start the width on the right side of the float 1 element from the left edge = [[_tabViews objectAtIndex : I-1] frame] .origin.x + [[_tabViews objectAtIndex: i-1] frame] .ize.width; TTTab * Tab = [_tabViews objectAtIndex: i]; [Tab set lift: (start + margin)]; }} And {// normal, scrollbar arguments _scrollView.contentOffset = contentOffset; } The size of the return; } @end  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -