我正在从iphone应用程序中的照片库中选择一个图像.我将如何检索实际图像名称.
在.h班
UIImageView * imageView;
UIButton * choosePhotoBtn;
Run Code Online (Sandbox Code Playgroud)
在.m级
-(IBAction) getPhoto:(id) sender
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn)
{
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
else
{
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
Run Code Online (Sandbox Code Playgroud)
我如何获得图像的实际名称?
我是iphone的新手.请帮我.
提前致谢.
如何找到被点击的引脚的引脚ID(即引脚标题和副标题的详细信息)?
我有这个来显示引脚注释.这段代码在视图中加载:
[resultCoordinate addObjectsFromArray:[sqlClass return_Coordinate]];
if ([resultCoordinate count])
{
for (int i =0; i < [resultCoordinate count]; i++)
{
dict = [resultCoordinate objectAtIndex:i];
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = [[dict objectForKey:@"Lati"] floatValue];
region.center.longitude = [[dict objectForKey:@"Longi"] floatValue];
region.span.longitudeDelta = 0.2f;
region.span.latitudeDelta = 0.2f;
NSString *fishName = [dict objectForKey:@"Fish"];
fishName = [fishName stringByAppendingString:@" "];
NSString *fishWeight = [dict objectForKey:@"Weight"];
fishWeight = [fishWeight stringByAppendingString:@" kg"];
fishName = [fishName stringByAppendingString:fishWeight];
MapAnnotation *ann = [[MapAnnotation alloc] …Run Code Online (Sandbox Code Playgroud) 我是iphone开发的新手.我有一个问题.我想在NSString中转换NSTimeInterval值,但在此不成功.请快速查看下面的代码.
在.h
NSTimeInterval startTime;
NSTimeInterval stopTime;
NSTimeInterval duration;
Run Code Online (Sandbox Code Playgroud)
在.m
startTime = [NSDate timeIntervalSinceReferenceDate];
stopTime = [NSDate timeIntervalSinceReferenceDate];
duration = stopTime-startTime;
NSLog(@"Duration is %@",[NSDate dateWithTimeIntervalSinceReferenceDate: duration]);
NSLog(@"Duration is %@", [NSString stringWithFormat:@"%f", duration]);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSString *time = [dateFormatter stringFromDate:duration];----> Error
[dateFormatter release];
Run Code Online (Sandbox Code Playgroud)
并在一个标签上设置此字符串----
[timeLabel setText:time];
Run Code Online (Sandbox Code Playgroud)
但它不起作用它显示错误:'stringFromDate:'的参数1的不兼容类型
如果我评论该行,它会在控制台窗口中显示正确的持续时间.
谢谢你的帮助.
我只是在引脚注释上加载一个带有自定义引脚图像的简单地图.第一次正确加载地图中的图像.当我更改地图类型时,引脚会以默认格式更改.你对这个问题有任何想法.任何帮助将不胜感激.谢谢.