项目总结
1.获取调用者所在视图控制器的类名
NSString *className = [NSString stringWithUTF8String:class_getName([self class])];
2.UIPopoverController的用法
引入头文件:
。h
《UIPopoverControllerDelegate 》
。m
UIPopoverController *_popover = [[UIPopoverController alloc] initWithContentViewController:_reportListViewController];
_popover.delegate = self;
[_popover setPopoverContentSize:CGSizeMake(330,330)];
_reportListViewController.contentSizeForViewInPopover=_reportListViewController.view.bounds.size;
[_popover presentPopoverFromRect:button.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
[_reportListViewController release];
实现代理方法:
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
if (popoverController) {
[popoverController dismissPopoverAnimated:YES];
[popoverController release];
popoverController=nil;
}
}
3.本地化
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSMutableArray *historyList = [NSMutableArray arrayWithArray:[userDefaults arrayForKey:kReportHistory]];
/*中间存数据*/
[userDefaults synchronize];
go on...
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/%@.pdf", documentsDirectory, [dict objectForKey:kReportID]];
// 判断报告文件是否存在
NSFileManager *fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath:filePath])
{
// 打开本地报告文件
NSString *phrase = nil;
ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:phrase];
if (document != nil)
{
:::Pdf Reader类库打酱油:::
ReaderViewController *readerViewController = [[[ReaderViewController alloc] initWithReaderDocument:document] autorelease];
readerViewController.delegate = self;
[readerViewController setMainToolBarTitle:[dict objectForKey:kReportTitle]];
readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
readerViewController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:readerViewController animated:YES];
}
else
{
hint(@"打开报告文件失败!请重试!");
}
}
else
{
// 下载报告文件
[self hint:@"该报告还未下载,是否现在下载?" trueBlock:^{
downloadReportIndex = reportIndex;
sIndexPath = indexPath;
_HUD = [[MBProgressHUD showHUDAddedTo:_reportList animated:YES] retain];
_HUD.delegate = self;
_HUD.labelText = @"网络连接中...";
_HUD.minSize = CGSizeMake(135.f, 135.f);
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]];
request.queue = self;
[request setDownloadDestinationPath:filePath];
[request startAsynchronous];
}];
}

浙公网安备 33010602011771号