Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6797101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:34:02+00:00 2026-05-26T18:34:02+00:00

I have an object that I init like so: pdtd = [[ProfileDataTableDelegate alloc] initWithTableView:profileDataTableView

  • 0

I have an object that I init like so:

pdtd = [[ProfileDataTableDelegate alloc] initWithTableView:profileDataTableView scrollView:contentScrollView];

so my view is passed to the pdtd object. I can log my view out at this point with no problem. I get the error when I click inside a text field and the scroll view is told to reposition. It’s on my table delegate (pdtd) that I get the error which gives me “EXC_BAD_ACCESS” in the first line of this function:

- (void)keyboardDidShow:(NSNotification *)notif {
    [self.scrollView setContentOffset:CGPointMake(0, 100) animated:YES]; // <-- ERROR SHOWS UP HERE

    [self.scrollView setContentSize:CGSizeMake([self.scrollView frame].size.width, 
                                               [self.scrollView frame].size.height + 100)];
}

Which is weird because I’m doing this on another view and it works fine. I’m not sure what’s wrong or how to get more info from the debugger. Below are related functions from the associated classes.

ProfileViewController.h

...

#import "ProfileDataTableDelegate.h"


@interface ProfileViewController : UIViewController <UINavigationControllerDelegate> {
    UITableView *profileDataTableView;
    ProfileDataTableDelegate *pdtd;
    UINavigationBar *navBar;
    UIScrollView *contentScrollView;
}

...

@property (nonatomic, retain) IBOutlet UITableView *profileDataTableView;
@property (nonatomic, retain) ProfileDataTableDelegate *pdtd;
@property (nonatomic, retain) IBOutlet UINavigationBar *navBar;
@property (nonatomic, retain) IBOutlet UIScrollView *contentScrollView;

@end

ProfileViewController.m

...

- (void)viewDidLoad {
    [super viewDidLoad];

    //nav title
    [navBar.topItem setTitle:@"Your Profile"];

    [self.navigationController setNavigationBarHidden:NO];

    // nav bar button
    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@"Save" style:UIBarButtonItemStyleDone target:self action:@selector(saveBtnTouched:)];
    saveButton.enabled = false;
    [navBar.topItem setRightBarButtonItem:saveButton];

    pdtd = [[ProfileDataTableDelegate alloc] initWithTableView:profileDataTableView scrollView:contentScrollView];

    void (^block)(BOOL) = ^(BOOL is_valid) {
        if(is_valid == YES) {
            [saveButton setEnabled:YES];
        } else if(is_valid == NO) {
            [saveButton setEnabled:NO];
        }
    };

    [pdtd setValidatorBlock:block];
}

...

ProfileDateTableDelegate.h

...

#import "ValidatedTextViewTableCell.h"

typedef void (^ ValidatorBlock)(BOOL);

@interface ProfileDataTableDelegate : NSObject <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate> {
    UITableView *profileDataTableView;
    UIScrollView *scrollView;

        ...
}

- (id)initWithTableView:(UITableView *)tableView scrollView:(UIScrollView *)scrollView;

...

@property (nonatomic, retain) IBOutlet UITableView *profileDataTableView;
@property (nonatomic, retain) UIScrollView *scrollView;

@end

ProfileDateTableDelegate.m

...

@implementation ProfileDataTableDelegate

@synthesize profileDataTableView;
@synthesize profileDataTableLabels;
@synthesize scrollView;

@synthesize emailCell, phoneCell, nameCell;
@synthesize validatedTextViewTableCell;
@synthesize validatorBlock;


- (id)initWithTableView:(UITableView *)tableView scrollView:(UIScrollView *)view {
    self = [super init];

    if(self) {
        profileDataTableView = tableView;
        [profileDataTableView setDelegate:self];
        [profileDataTableView setDataSource:self];

        scrollView = view;

        profileDataTableLabels = [[NSArray alloc] initWithObjects:@"Name", @"Email", @"Phone", nil];

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector (keyboardDidShow:)
                                                     name: UIKeyboardDidShowNotification object:nil];

        [[NSNotificationCenter defaultCenter] addObserver:self 
                                                 selector:@selector (keyboardDidHide:)
                                                     name: UIKeyboardDidHideNotification object:nil];
    }

    return self;
}

...

- (void)keyboardDidShow:(NSNotification *)notif {
    //NSLog(@"keyboard did show %@", notif); // notif gives coordinates etc
    //[scrollView setContentOffset:CGPointMake(0, 480 - 372) animated:YES];

    [self.scrollView setContentOffset:CGPointMake(0, 100) animated:YES];

    [self.scrollView setContentSize:CGSizeMake([self.scrollView frame].size.width, 
                                               [self.scrollView frame].size.height + 100)];

    //[scrollView setFrame:CGRectMake(0, 0, 320, 320)];


    // disable scrolling because it resets the rect position
    //[scrollView setScrollEnabled:NO];
}

...

@end

I’m not sure how to get stack trace info (Xcode 4.2). Also, on analyze there are a couple of warnings, but nothing serious (eg. blue).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:34:03+00:00Added an answer on May 26, 2026 at 6:34 pm

    You need to call self.scrollView = view OR scrollView = [view retain] in your initWithTableView: method in ProfileDateTableDelegate.m.

    Basically what is happening is that your scrollView is being released in some other view before you are able to access it since your “delegate” class does not retain it in any way, even though you have specified nonatomic,retain on your property. Since you are setting the ivar directly in init instead of using the setter property, the retain is not being called on it. When using the ivar directly, you must call retain yourself if you want it retained.

    One way to avoid this error is to use an underscore _ before or after your ivars (Apple uses before, so I use after to avoid private ivar collisions), like so:

    in .h:

    @interface{
        UIScrollView *scrollView_;
    }
    
    @property (nonatomic,retain) UIScrollView *scrollView;
    

    in *.m:

    @synthesize scrollView = scrollView_;
    

    Then, you in init, you can retain the view coming in like so:

    scrollView_ = [view retain];
    

    Just make sure you properly release it in dealloc:

    - (void)dealloc{
        [scrollView_ release], scrollView_ = nil;
        [super dealloc];
    }
    

    You can find more info about all this here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object that I alloc/init like normal just to get a instance.
I have an object that can build itself from an XML string, and write
I have a Handler object that functions kind of like a service. It has
I have an object MObject that is currently defined like so: + (id)objectWithType:(NSString*)type name:(NSString*)name
I have an object Foo that has an NSNumber property which is declared like
I have an object that can't be dumped by simplejson , so I need
I have two tables: object that has object_id column and avalues that have object_id
I have an object that is mapped to a cookie as a serialized base-64
I have an object that implements IDisposable that is registered with the Windsor Container
I have an object that needs a test if the object data is valid.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.