我想知道在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];
}
然后实现委托方法:
- (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
}
}