Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS 5 ScrollView Adding SubViews Causes EXC_BAD_ACCESS
    text
    copied!<p>ARC, iOS 5, XCode 4.2</p> <p>I am trying to implement a paged scroll view with a page control (similar to the Home screen), and I can't seem to get it to work. The relevant code is:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [scroll setDelegate:self]; [scroll setContentSize:CGSizeMake(2 * [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)]; [scroll setPagingEnabled:YES]; pageControl.currentPage = 0; pageControl.numberOfPages = 2; UIView* view = [[self.storyboard instantiateViewControllerWithIdentifier:@"VALID_ID_1"] view]; view.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height); [scroll addSubview:view]; UIView *aView = [[self.storyboard instantiateViewControllerWithIdentifier:@"VALID_ID_2"] view]; aView.frame = CGRectMake([[UIScreen mainScreen] bounds].size.width, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height); [scroll addSubview:aView]; } </code></pre> <p>Calling the <code>instantiateViewControllerWithIdentifier</code> method returns a result.</p> <p><strong>Things I have tried:</strong></p> <ul> <li>Disabling ARC on this particular file</li> <li>Using <code>alloc] init]</code> on the view controller</li> </ul> <p><strong>EDIT</strong>: I should probably show the declaration:</p> <pre><code>//MyViewController.h @property (strong, nonatomic) IBOutlet UIScrollView* scroll; ... //MyViewController.m @synthesize scroll; </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