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 4334042
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:28:30+00:00 2026-05-21T10:28:30+00:00

I am currently writing my first iPhone app, but have encountered an issue. I

  • 0

I am currently writing my first iPhone app, but have encountered an issue. I have a view which contains a UITableView. This is the first time that I have attempted this, and this is the behaviour that I am trying to achieve:

When the user selects one of the rows, I would like this to call a new view, taking the user to a different page displaying info in reference to what they have selected.

I have it currently, so when the user selects a row it displays a UIAlert in the same view, but this doesn;t suit my needs. I have set the UITableView up through interface builder, and inputted the following code into my .m file to set it up.

- (NSInteger)tableView:(UITableView *)tableView 
 numberOfRowsInSection:(NSInteger)section {
    //return the value
    return 10;
}

//now we define the cells.
- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    // Identifier for retrieving reusable cells.
    static NSString *cellIdentifier = @"MyCellIdentifier";

    // Attempt to request the reusable cell.
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

    // No cell available - create one
    if(cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
                                      reuseIdentifier:cellIdentifier];
    }

    // Set the text of the cell to the row index.
    cell.textLabel.text = [NSString stringWithFormat:@"iPad %d", indexPath.row];

    return cell;
}

This creates a list of ten rows. The following codes gives me my UIAlert when tapped, however, I want to remove this and make it call a new view of my choice;

- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    // Show an alert with the index selected.
    UIAlertView *alert = [[UIAlertView alloc] 
                          initWithTitle:@"iPad Selected"                         
                          message:[NSString stringWithFormat:@"iPad %d", indexPath.row]                     
                          delegate:self       
                          cancelButtonTitle:@"OK"           
                          otherButtonTitles:nil];
    [alert show];
    [alert release];   

}

Can anyone help with this last piece of code? the view I want it to call is called ‘ProteinView’.

  • 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-21T10:28:30+00:00Added an answer on May 21, 2026 at 10:28 am

    Alrighty, what we need to do is use one of the UITableView methods that are already readily available to us. We’ll do the following.

    - (void)tableView:(UITableView *)tableView 
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    ProteinView *detailViewController = [[ProteinView alloc] initWithNibName:@"ProteinView" bundle:nil];
    
            // It is here we'd pass information from the currently selected UITableViewCell to the ProteinView.
            // An example of this is the following.
    
            // I would do it like this, but others would differ slightly.
            NSString *titleString = [[[NSString alloc] initWithFormat:@"iPad %d",indexPath.row] autorelease];
    
            // title is an object of detailViewController (ProteinView). In my own instances, I have always made a NSString which in viewDiDLoad is made the self.navigationBar.title string. Look below for what my ProteinView.m and .h would look like.
            detailViewController.stringTitle = titleString;
            // ...
            // Pass the selected object to the new view controller.
            [self.navigationController pushViewController:detailViewController animated:YES];
            [detailViewController release];
    }
    

    EDIT

    // -------- ProteinView.m -------- //
    
    - (void)viewDidLoad {
    
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    // Here we set the navigationItem.title to the stringTitle. stringTitle is declared in the .h. Think of it as a global scope variable. It is also propertised in the .h and then synthesized in the .m of ProteinView. 
    self.navigationItem.title = stringTitle;
    }
    

    I haven’t compiled this, so I don’t know if it’ll fully work. But that is definitely the fastest and most easiest way to do it!

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

Sidebar

Related Questions

I am currently writing my first Android app and have based most of my
the iphone app I am writing shows white screen when first launched, but become
I'm currently writing a client-side javascript app which performs image manipulation. Some of the
I'm currently writing a plugin and have run into and issue that, from searching
Long time lurker, first time asker. I am currently writing a custom theme for
i'm writing my first iPhone app with aim to upload it to the AppStore
I'm currently writing a small test Android app, and have run across a small
I am currently writing a Batch file (first time doing so) to remotely call
The application I'm currently writing is using MVVM with the ViewModel-first pattern. I have
I am currently writing my truly first PHP Application and i would like to

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.