Note that there are some explanatory texts on larger screens.

plurals
  1. POUIScrollView phantom subviews
    primarykey
    data
    text
    <p>I am loading a view from a nib file using:</p> <pre><code>NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"AnalysisView" owner:self options:nil]; AnalysisView *gridView = [nibViews objectAtIndex: 0]; </code></pre> <p>The nib contains a scrollview called gridScrollView and in the AnalysisView implementation file I have a method which adds views as subviews to the scrollview:</p> <pre><code>for (NSInteger i = [results count] -1; i &gt;= 0; i--) { Result *result = [results objectAtIndex:i]; [self loadResult: result]; } - (void) loadResult: (Result *) result { NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"GridView" owner:self options:nil]; GridView *gridView = [nibViews objectAtIndex: 0]; gridView.tag = self.graphCount; CGRect gridFrame = gridView.frame; CGFloat yOffset = gridFrame.size.height * self.graphCount; gridView.frame = CGRectMake(0, yOffset, gridFrame.size.width, gridFrame.size.height); [self.gridScrollView addSubview: gridView]; self.gridScrollView.contentSize = CGSizeMake(self.gridScrollView.frame.size.width, (yOffset + gridFrame.size.height)); self.graphCount++; } </code></pre> <p>I have set the scrollviews delegate to be AnalysisView and hooked up the did end decelaring method</p> <pre><code>-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { NSLog(@"%d", [scrollView.subviews count]); } </code></pre> <p>When the scrollViewDidEndDecelerating method fires it reports that the number of subviews is 5. 3 of these subviews are GridViews which I expect. However there are 2 UIImageViews which I have no idea why they are there.</p> <p>This is an issue because I intend on retrieving the views with viewWithTag in the scrollViewDidEndDecelerating method and calling a method on the view, however whenever I try to retrieve a view with a tag of 0 I will retrieve one of the UIImageView's and this causes my app to crash because the method cannot be called on an image view.</p> <p>I know a way round this is to store my GridViews in a seperate instance array and reference them from there. But I'm curious to know what the 2 UIImageViews are and how they got there.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload