我已设置以下代码将文件保存到文档目录:
NSLog(@"Saving File...");
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.reddexuk.com/logo.png"]];
AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:request] autorelease];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"logo.png"];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Successfully downloaded file to %@", path);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
[operation start];
Run Code Online (Sandbox Code Playgroud)
但是,我希望在成功保存后将每个文件添加到UITableView.当点击UITableView中的文件时,我想要一个UIWebView导航到该文件(所有离线).
另外 - 我怎样才能获得文件名和结尾,例如"logo.png"而不是http://www.reddexuk.com/logo.png?
我怎样才能做到这一点?
我如何创建一个"下载管理器",它可以检测您点击的链接(在UIWebView中)何时文件结尾为".pdf",".png",".jpeg",".ifff",".gif" ,".doc",".dococ",".pt",".ptx",".xls"和".xlsx",然后会打开一个UIActionSheet,询问您是否要下载或打开.如果选择下载,则会将该文件下载到设备.
该应用程序的另一部分将在UITableView中有一个下载文件列表,当您点击它们时,它们将显示在UIWebView中,但当然是离线的,因为它们将在本地加载,因为它们将被下载.
请参阅http://itunes.apple.com/gb/app/downloads-lite-downloader/id349275540?mt=8,以便更好地了解我要做的事情.
这样做的最佳方式是什么?
如何在XCode中更改UITableView单元格标题的字体大小?
谢谢
我已经实现了所有ASIHTTPRequest文件,但遗憾的是发生了以下错误:


为什么会这样?
是否可以从现有的XCode项目创建模板以反复使用但具有不同的应用程序名称?
谢谢!
我已将以下代码添加到我的应用中:
NSDate * selected = [DatePicker date];
NSString * date = [selected description];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit
fromDate:DatePicker.date];
CalLabel1.text = [NSString stringWithFormat:@"%d", [components day]];
EKEventStore *store = [[EKEventStore alloc] init];
EKEvent *event = [EKEvent eventWithEventStore:store];
event.title = @"Test Event";
//required
event.startDate = [DatePicker date];
event.endDate = [DatePicker date];
event.calendar = store.defaultCalendarForNewEvents;
//end
NSError *err;
[store saveEvent:event span:EKSpanThisEvent error:&err];
Run Code Online (Sandbox Code Playgroud)
为什么这不会在iOS日历中添加任何内容?
谢谢.
我正在使用以下代码,但在开始编辑UITextView时无法识别它:
-(void)textViewDidBeginEditing:(UITextView *)textView{
[done setHidden:NO];
NSLog(@"Started editing target!");
}
Run Code Online (Sandbox Code Playgroud)
为什么是这样?
我也将代理添加到.h文件中.
我已经尝试过尝试使每一段代码尝试使这一页放大和缩小,但无论如何,文本仍然与屏幕重叠,UIWebView中的页面根本不适合屏幕.
我在这里试过说明:http://www.iphonedevsdk.com/forum/iphone-sdk-development/9112-uiwebview-zoom-pinch.html
我试过添加: webView.scalesPageToFit = TRUE;
我把它设置为UserInteractionEnabled.
但似乎没有任何工作.
这是与网页的编码有关还是与UIWebView有关?
谢谢,
詹姆士
在编辑我的UITextView时,我想要一个按钮出现.我怎样才能做到这一点?
谢谢!
如何判断从现在到我的应用中指定的日期的天数?这是我到目前为止所拥有的,但无论日期是什么,它每次都会出现"-30":
NSDate * selected = [DatePicker date];
NSString * date = [selected description];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit
fromDate:DatePicker.date];
CalLabel1.text = [NSString stringWithFormat:@"%d", [components day]];
NSDateFormatter *temp = [[NSDateFormatter alloc] init];
[temp setDateFormat:@"dd/MM/yyyy"];
NSDate *stDt = [temp dateFromString:[temp stringFromDate:[NSDate date]]];
NSDate *endDt = [temp dateFromString:[temp stringFromDate:[NSString stringWithFormat:@"%d", [components date]]]];
unsigned int unitFlags = NSMonthCalendarUnit | NSDayCalendarUnit;
NSCalendar *gregorian = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps = [gregorian components:unitFlags fromDate:stDt toDate:endDt options:0];
int days = [comps day];
NSLog(@"%i", [comps day]);
Run Code Online (Sandbox Code Playgroud) ios ×10
xcode ×9
iphone ×8
objective-c ×8
uitextview ×2
uiwebview ×2
afnetworking ×1
download ×1
eventkit ×1
html ×1
nsdate ×1
scale ×1
templates ×1
uidatepicker ×1
uitableview ×1