Note that there are some explanatory texts on larger screens.

plurals
  1. POButtons in ScrollView not enabled
    text
    copied!<p>Using Erica Sadun's scroll view example I created a project. I now have a scroll view and a page control in my project. I create a new view for each page and add it to my scroll view as seen below. Each view has 5 buttons so I can scroll 5 by 5. However the buttons do not seem to be enabled. Any ideas why?</p> <pre><code> // Create the scroll view and set its content size and delegate sv = [[[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 200.0f, 300.0f, 60.0f)] autorelease]; sv.contentSize = CGSizeMake(NPAGES * 300.0f, sv.frame.size.height); sv.pagingEnabled = YES; sv.delegate = self; // Load in all the pages for (int i = 0; i &lt; NPAGES; i++) { UIView *menuView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 300.0f, 60.0f)]; for (int j = 0; j &lt; 5 * (i+1); j++) { UIImage *menuImage = [UIImage imageNamed:@"menuimage.png"]; UIImage *menuImage2 = [UIImage imageNamed:@"menuimageselected.png"]; UIButton *menuButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; menuButton.frame = CGRectMake(j * 60.0f, 0.0f, 60.0f, 60.0f); [menuButton addTarget:self action:@selector(menuButtonClicked) forControlEvents:UIControlEventTouchUpInside]; menuButton.tag = j + 5 * i; menuButton.backgroundColor = [UIColor clearColor]; [menuButton setImage:menuImage forState:UIControlStateNormal]; [menuButton setImage:menuImage2 forState:UIControlStateSelected]; [menuButton setImage:menuImage2 forState:UIControlStateHighlighted]; [menuButton setEnabled:YES]; [menuImage release]; [menuButton release]; [menuView addSubview:menuButton]; } [sv addSubview:menuView]; [sv bringSubviewToFront:menuView]; [menuView release]; } [self.view addSubview:sv]; </code></pre>
 

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