我想在我的iPhone应用程序中获取当前城市名称.
我目前正在使用CLLocationManager获取纬度和经度,而不是将我的坐标传递给CLGeocoder.
CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
[geoCoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
for (CLPlacemark * placemark in placemarks) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Current City" message:[NSString stringWithFormat:@"Your Current City:%@",[placemark locality]] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Cancel", nil];
[alert show];
}
}];
Run Code Online (Sandbox Code Playgroud)
这在iOS 5.0中运行良好,但在iOS 4.3中无效.
作为替代方案,我开始使用Google Web服务
-(void)findLocationFor:(NSString *)latitudeStr
andLontitude:(NSString *)longtitudeStr{
if ([self connectedToWiFi]){
float latitude = [latitudeStr floatValue];
float longitude = [longtitudeStr floatValue];
NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:@"%f,%f", latitude, longitude], @"latlng", nil];
NSMutableURLRequest *request = [NSMutableURLRequest …Run Code Online (Sandbox Code Playgroud) 我希望用户选择她/他的iPhone中存在的任何文件,以便将其用作电子邮件附件.为此,我想显示iPhone中存在的所有文件和文件夹的列表.但是我如何获得这些文件的列表?有没有办法获得该名单?
我在我的应用程序中实现了本地通知,但我只是想知道是否有一种方法可以播放不属于主要iPhone应用程序包的声音.基本上在我的应用程序中,我希望用户录制在生成本地通知时播放的声音,而不是播放预先录制的或默认声音.据我所知,这可以实现,因为我已经在应用程序商店中看到2-3个应用商店正在做同样的事我想做
- (void)alertSelector:(NSString *)AlertTitle WithFiringTime:(NSDate *)date
{
UILocalNotification *localNotification = [[[UILocalNotification alloc] init] autorelease];
[localNotification setFireDate:date];
[localNotification setTimeZone:[NSTimeZone defaultTimeZone]];
NSDictionary *data = [NSDictionary dictionaryWithObject:date forKey:@"payload"];
[localNotification setUserInfo:data];[localNotification setAlertBody:AlertTitle];
[localNotification setAlertAction:@"View"]; [localNotification setHasAction:YES];
localNotification.soundName=@"voice.aif";
if (!localNotification)
return;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
}
Run Code Online (Sandbox Code Playgroud) 有没有办法从UIWebView我在我的IBAction活动中使用此代码下载文件
- (IBAction)saveFile:(id)sender {
// Get the URL of the loaded ressource
NSURL *theRessourcesURL = [[self.webDisplay request] URL];
NSString *fileExtension = [theRessourcesURL pathExtension];
if ([fileExtension isEqualToString:@"png"] || [fileExtension isEqualToString:@"jpg"] ||
[fileExtension isEqualToString:@"pdf"] || [fileExtension isEqualToString:@"html"]) {
// Get the filename of the loaded ressource form the UIWebView's request URL
NSString *filename = [theRessourcesURL lastPathComponent];
NSLog(@"Filename: %@", filename);
// Get the path to the App's Documents directory
NSString *docPath = [self documentsDirectoryPath];
// Combine the filename and …Run Code Online (Sandbox Code Playgroud) 在我的 iOS 应用程序中,如何播放存储在应用程序文档目录中的声音文件以用于本地通知,而不是应用程序包中的声音文件?
我在 App Store 上看到了几个应用程序这样做,我想知道这怎么可能。
我在我的UIWebView中打开本地Pdf文件,而不是尝试调整UIWebview的大小,使得WebView高度等于WebView内容高度我正在使用这行代码来获取WebView内容的高度
- (float) getWebViewContentHeight:(UIWebView *)view
{
CGRect aFrame = view.frame;
aFrame.size.height = [view sizeThatFits:[[UIScreen mainScreen] bounds].size].height;
view.frame = aFrame;
return view.frame.size.height;
}
Run Code Online (Sandbox Code Playgroud)
这段代码在iOS 4.3上完美运行,但在iOS 5.0上无法工作,任何人都可以帮助我了解如何获取webView的内容大小或使这段代码适用于iOS 5
我想将文件从我的iPhone wifi网络上的系统(mac/Pc)传输到我的iPhone App的文件夹.我的应用程序的场景就是这样,它将浏览网络中存在的系统.从该系统中选择任何文件(例如.pdf或docx)(mac/Pc),将其复制到APP的文档文件夹中,然后在APP中使用它.在我的搜索中,我遇到链接iPhone:转移从Mac/Pc到app的文件我没有找到详细的说明文件,如何使用它.Apple是否支持任何API或农场工作?请指导我
ios ×7
iphone ×7
objective-c ×4
cocoa-touch ×2
filesystems ×1
foundation ×1
google-maps ×1
ios5 ×1
ipad ×1
pdf ×1
uiwebview ×1