简体   繁体   中英

tableview in iOS7

I want to know that in ios7, Is it use the prepareForSegue method instead of the didSelectAtIndexPath method?

if yes, how can I change the follow code that can run in ios7?

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *tempSqlStatement = @"";
NSString *tempString = @"%";
databaseName = @"TCMdb8.sql";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [documentsDir stringByAppendingPathComponent:
                databaseName];
if (buttonNum == 0) {

    Function1DetailViewController *function1DetailViewController =
   [[Function1DetailViewController alloc] initWithKey:[listOfItems objectAtIndex:indexPath.row] type:@"1"];

 [self.navigationController pushViewController:function1DetailViewController animated:YES];
}else if (buttonNum != 0){
    if (buttonNum == 1) {
        tableTitle = @"xxxx";
        tempSqlStatement = [NSString stringWithFormat:@"select name from Medicine where stroke ='%@' ORDER BY length(name) ASC", [listOfItems objectAtIndex:indexPath.row]];
         function1SQLStatement = [tempSqlStatement UTF8String];
  }
    [self checkAndCreateDatabase];
    [self readFromDatabase];
    [tableList reloadData];
    buttonNum = 0;

}

This has been available since iOS2. You will need few changes:

if (buttonNum == 0) {
    [self performSegueWithIdentifier:@"Function1Segue" sender:sender];
}

Then implement the deleguate method:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"Function1Segue"])
    {
        // Get reference to Function1DetailViewController
        //Create new Instance here, and set its properties values
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM