Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling a New View when selecting a Row in a 'UITableView'
    primarykey
    data
    text
    <p>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:</p> <p>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.</p> <p>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.</p> <pre><code>- (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; } </code></pre> <p>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;</p> <pre><code>- (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]; } </code></pre> <p>Can anyone help with this last piece of code? the view I want it to call is called 'ProteinView'.</p>
    singulars
    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.
    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