我使用的是故事板的項目。問題是它不能推到Function1DetailViewController.Moreover,因爲tableview沒有內部的單元格,我不知道如何繪製segue之間的鏈接兩個視圖控制器。另外,我不知道如何編寫prepareForSegue方法。iOS7中的prepareForSegue方法
我是否還需要在didSelectRowAtIndexPath方法中進行一些更改?
-(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) {
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;
}
}
prepareForSegue方法中的一些錯誤。它是'使用未聲明的標識符'indexPath'。你的意思是'NSIndexPath'?' – user2914810
仔細閱讀我的答案!你需要標識符! http://i.stack.imgur.com/OJ7aJ.png :) – meda
我的意思是代碼'functionVC.item = [listOfItems objectAtIndex:indexPath.row] type:@「1」];'得到這個錯誤 – user2914810