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

  • SEARCH
  • Home
  • 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 4094494
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:45:07+00:00 2026-05-20T19:45:07+00:00

I am quite new to IOS development, so forgive me if this problem turns

  • 0

I am quite new to IOS development, so forgive me if this problem turns out to be trivial. The following is the case:

I want to be able to call the didSelectRowAtIndexPath method to trigger some action when a user interacts with a table view cell. However, it seems that this method is never called for some reason. I am fairly certain that my code is valid. I set the delegate and dataSource properties and I conform to the UITableViewDelegate and UITableViewDataSource protocols.

If someone could shed some light on this, I would be very grateful.

My code:

#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
@class Employee;

#define kTelephoneRowIndex  0
#define kEmailRowIndex      1
#define kLeftLabelTag        4096
#define kRightLabelTag      4097


@interface PersonnelDetailsViewController : UIViewController <UITableViewDelegate,  
UITableViewDataSource, MFMailComposeViewControllerDelegate> {
    UITableView *contactDetailsTable;
Employee *employee;
}

@property (nonatomic, retain) UITableView *contactDetailsTable;
@property (nonatomic, retain) Employee *employee;

+ (NSString *)resourceFilePath:(NSString *)fileName ofType:(NSString *)type;


@end

and my .m file

#import <QuartzCore/QuartzCore.h>
#import "PersonnelDetailsViewController.h"
#import "Employee.h"


@implementation PersonnelDetailsViewController

@synthesize contactDetailsTable, employee;


+ (NSString *)resourceFilePath:(NSString *)fileName ofType:(NSString *)type {
return [[NSBundle mainBundle] pathForResource:fileName ofType:type];
}

- (void)loadView {
[super loadView];

// Create the header view for the table view
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 110)];

// Set the image, using rounded corners
UIImage *employeeImage;
if ([employee.image length] == 0)
    employeeImage = [UIImage imageNamed:@"logoL1nda70by80"];
else
    employeeImage = [UIImage imageNamed:employee.image];

UIImageView *employeeImageView = [[UIImageView alloc] initWithImage:employeeImage];
employeeImageView.frame = CGRectMake(10, 15, 70, 80);
employeeImageView.layer.masksToBounds = YES;
employeeImageView.layer.cornerRadius = 5.0;
employeeImageView.layer.borderWidth = 1.0;
employeeImageView.layer.borderColor = [[UIColor grayColor] CGColor];
[headerView addSubview:employeeImageView];

UILabel *nameView = [[UILabel alloc] initWithFrame:CGRectMake(95, 35, 180, 20)];
nameView.text = employee.name;
nameView.font = [UIFont boldSystemFontOfSize:18];
[headerView addSubview:nameView];

UILabel *functionView = [[UILabel alloc] initWithFrame:CGRectMake(95, 55, 140, 16)];
functionView.text = employee.function;
functionView.textColor = [UIColor grayColor];
functionView.font = [UIFont systemFontOfSize:14];
[headerView addSubview:functionView];

[employeeImage release];
[employeeImageView release];
[nameView release];
[functionView release];

contactDetailsTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 370) style: UITableViewStyleGrouped];
contactDetailsTable.backgroundColor = [UIColor clearColor];
contactDetailsTable.tableHeaderView = headerView;
[headerView release];
contactDetailsTable.delegate = self;
contactDetailsTable.dataSource = self;

[self.view addSubview:contactDetailsTable];
}

- (void)viewDidUnload {
self.contactDetailsTable = nil;
self.employee = nil;

[super viewDidUnload];
}

- (void)viewWillAppear:(BOOL)animated {
[contactDetailsTable reloadData];
}

- (void)dealloc {
[contactDetailsTable release];
[employee release];
[super dealloc];
}

#pragma mark -
#pragma mark Table View Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 2;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;did
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *contactDetailIdentifier = @"contactDetailIdentifier";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:contactDetailIdentifier];

if (cell == nil) {      
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                   reuseIdentifier:contactDetailIdentifier] autorelease];
    UILabel *leftLabel = [[UITextField alloc] initWithFrame:CGRectMake(5, 12, 70, 25)];
    leftLabel.textAlignment = UITextAlignmentRight;
    leftLabel.textColor = [UIColor grayColor];
    leftLabel.tag = kLeftLabelTag;
    leftLabel.userInteractionEnabled = NO;
    [cell.contentView addSubview:leftLabel];
    [leftLabel release];

    UILabel *rightLabel = [[UITextField alloc] initWithFrame:CGRectMake(90, 12, 160, 25)];
    rightLabel.font = [UIFont boldSystemFontOfSize:16];
    rightLabel.tag = kRightLabelTag;
    rightLabel.userInteractionEnabled = NO;
    [cell.contentView addSubview:rightLabel];
    [rightLabel release];
}
NSUInteger row = [indexPath row];
UILabel *leftLabel = (UILabel *)[cell viewWithTag:kLeftLabelTag];
UILabel *rightLabel = (UILabel *)[cell viewWithTag:kRightLabelTag];

switch (row) {
    case kTelephoneRowIndex:
        leftLabel.text = @"telefoon";
        rightLabel.text = employee.phone;
        break;
    case kEmailRowIndex:
        leftLabel.text = @"e-mail";
        rightLabel.text = employee.email;
        break;
    default:
        break;
}

return cell;
}

#pragma mark -
#pragma mark Table View Delegate Methods
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = indexPath.row;

if (row == 1) {
    MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
    [mailController setToRecipients:[NSArray arrayWithObject:employee.email]];
    [mailController.navigationBar setTintColor:[UIColor blackColor]];

    [self presentModalViewController:mailController animated:YES];
    mailController.mailComposeDelegate = self;
    [mailController release];
}

NSLog(@"Row selected is: %d", row);
}

#pragma mark -
#pragma mark MFMailCompose View Delegate Methods
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[self dismissModalViewControllerAnimated:YES];
}


@end
  • 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-20T19:45:08+00:00Added an answer on May 20, 2026 at 7:45 pm

    Check the doc for tableView:willSelectRowAtIndexPath::

    Return an NSIndexPath object other than indexPath if you want another cell to be selected. Return nil if you don’t want the row selected.

    You are returning nil, basically saying the table view that you don’t want that row selected. Therefore tableView:didSelectRowAtIndexPath: is not called.

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

Sidebar

Related Questions

Many will find this question quite trivial, but since I'm quite new on iOS
I'm quite new here. I have a problem with the new iOS 5.1 slide-in
I am quite new to iOS development and just thought to take guidance from
I am quite new to iOS development and trying hard to develop an App.
I'm new to IOS development, and want to create something with tiles similar to
Disclaimer: I'm quite new to Obj-C and iOS (5, ARC enabled). The following implementation
I'm new in mono touch iOS/monotouch development. I want to make multi-level table in
I'm quite new to iOs Programming.. At the moment I'm wondering about following issue.
Still quite new to Haskell.. I want to read the contents of a file,
I'm quite new to OpenId and I'm having a bit of a problem understanding

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.