Note that there are some explanatory texts on larger screens.

plurals
  1. POIBAction in UIScrollview > Subview
    primarykey
    data
    text
    <p>Really hope u can help me! I have a strange problem with Subviews. I'm trying to do a simple IBAction in one of my Subviews but as soon as i click my button, it gives me some memory error. I tried to add it to a property and synthesize the button. </p> <p>I got one scrollview for horizontal scrolling, added a subview for vertical scrolling, the second subview holds a viewcontroller where my button stands.</p> <p>If i click that button i get a BAD ACCESS error. NSZombie gives me this error:</p> <blockquote> <p>2012-04-05 14:26:06.924 SlideAppTest[44978:f803] <em>*</em> -[SubSlide1Hoofdstuk3 performSelector:withObject:withObject:]: message sent to deallocated instance 0x6c4bfe0</p> </blockquote> <p>This is my code:</p> <p>// RootSlideHoofdstuk3.h (vertical scroll)</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface RootSlideHoofdstuk3 : UIViewController &lt;UIScrollViewDelegate&gt; { } @property (weak, nonatomic) IBOutlet UIScrollView *scrollView; @end </code></pre> <p>// RootSlideHoofdstuk3.m (vertical scroll)</p> <pre><code>#import "RootSlideHoofdstuk3.h" #import "SubSlide1Hoofdstuk3.h" @implementation RootSlideHoofdstuk3 @synthesize scrollView = _scrollView; - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidLoad { [super viewDidLoad]; _scrollView.pagingEnabled = YES; _scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width,_scrollView.frame.size.height); _scrollView.showsHorizontalScrollIndicator = NO; _scrollView.showsVerticalScrollIndicator = NO; _scrollView.scrollsToTop = NO; _scrollView.bounces = NO; _scrollView.delegate = self; SubSlide1Hoofdstuk3 *subslide1 = [[SubSlide1Hoofdstuk3 alloc] init]; CGRect frame = self.view.frame; frame.origin.x = 0; frame.origin.y = 0; subslide1.view.frame = frame; [_scrollView addSubview:subslide1.view]; } </code></pre> <p>// SubSlide1Hoofdstuk3.h (Slide viewcontroller)</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface SubSlide1Hoofdstuk3 : UIViewController { UIButton *button; } @property (nonatomic, retain) IBOutlet UIButton *button; @end </code></pre> <p>// SubSlide1Hoofdstuk3.m (Slide viewcontroller)</p> <pre><code>#import "SubSlide1Hoofdstuk3.h" @implementation SubSlide1Hoofdstuk3 @synthesize button = _button; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; } -(IBAction)buttonActie { NSLog(@"Button clicked!"); } - (void)viewDidUnload { [super viewDidUnload]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } </code></pre>
    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