簡體   English   中英

iOS7中的tableview

[英]tableview in iOS7

我想知道在ios7中,它使用prepareForSegue方法而不是didSelectAtIndexPath方法嗎?

如果是,如何更改可在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;

}

自iOS2開始提供。 您將需要進行一些更改:

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

然后實現deleguate方法:

- (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
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM