我正在尝试执行以下操作
ReaderController *readerController = [[[ReaderController alloc] init] autorelease];;
readerController.fileName = fileName;
[readerController handleSingleTap];
其中 handleSingleTap 是 ReaderController 中的一个方法,但我不能调用它..方法是下一个
- (void)handleSingleTap:(UITapGestureRecognizer *)recognizer
{
#ifdef DEBUGX
NSLog(@"%s", __FUNCTION__);
#endif
ReaderDocument *document = [ReaderDocument unarchiveFromFileName:SAMPLE_DOCUMENT];
if (document == nil) // Create a brand new ReaderDocument object the first time we run
{
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [searchPaths objectAtIndex:0];
NSString *path = [documentsDirectoryPath stringByAppendingPathComponent:[[NSString stringWithFormat:@"%@",fileName] stringByAppendingPathExtension:@"pdf"]];
[self checkAndCreatePList];
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:pListPath];
[plistDict setValue: [NSString stringWithFormat:@"%@",fileName] forKey:@"fileName"];
[plistDict writeToFile:pListPath atomically: YES];
// NSString *filePath = [[NSBundle mainBundle] pathForResource:path ofType:nil];
document = [[[ReaderDocument alloc] initWithFilePath:path password:nil] autorelease];
}
if (document != nil) // Must have a valid ReaderDocument object in order to proceed
{
ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
readerViewController.delegate = self; // Set the ReaderViewController delegate to self
#if (DEMO_VIEW_CONTROLLER_PUSH == TRUE)
[self.navigationController pushViewController:readerViewController animated:YES];
#else // present in a modal view controller
readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:readerViewController animated:YES];
#endif // DEMO_VIEW_CONTROLLER_PUSH
[readerViewController release]; // Release the ReaderViewController
}
}
有什么问题,为什么我不能调用此方法,我需要一些详细信息,感谢您的帮助
最佳答案
嗯,这很简单,你做到了:
[readerController handleSingleTap];
什么时候你应该做:
[readerController handleSingleTap:yourRecognizer];
或
[readerController handleSingleTap:nil];
如果您未能通过识别器参数,您将在需要 handleSingleTap:
时发送一个 handleSingleTap
信号
关于ios - 无法从另一个 ViewController 调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7230036/