我有一个应用程序,用户可以从内置的应用程序图像或从iPhone照片库中选择图像.我使用一个具有NSString保存属性的对象Occasion imagePath.
现在,在内置应用程序映像的情况下,我确实将文件名作为NSString一个保存[occasion imagePath].但是在用户从照片库中选择图像的第二种情况下,我得到了一个NSURL我想要转换为NSString能够将其保存在其中的图像[occasion imagePath.
是否有可能将其转换NSURL为NSString?
这是一个问题的视频:http://youtu.be/Jid0PO2HgcU
尝试从资产库中为UITableView中的[cell imageView]设置图像时出现问题.
图像已加载但在触摸(选择)该单元格之前不会出现在单元格中.这是我的代码设置单元格的imageView:
//Start loading the image using the image path
NSString *path = [occasion imagePath];
if (path != nil && [path hasPrefix:@"ass"])
{
NSLog(@"photo loaded from assets library");
//testing ALAssestLibrary
ALAssetsLibrary* assetsLibrary = [[ALAssetsLibrary alloc] init];
ALAssetsLibraryAssetForURLResultBlock resultsBlock = ^(ALAsset *asset)
{
ALAssetRepresentation *representation = [asset defaultRepresentation];
CGImageRef imageRef = [representation fullResolutionImage];
UIImage *image = [[UIImage alloc] initWithCGImage:imageRef];
[[cell imageView] setImage:[image imageByScalingAndCroppingForSize:CGSizeMake(36.0, 42.0)]];
[image release];
};
ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError *error){
NSLog(@"FAILED! due to error in domain …Run Code Online (Sandbox Code Playgroud) 涉及到我刚才的问题在这里.
我有资源库中图像的路径,例如:
assets-library://asset/asset.JPG?id=1000000001&ext=JPG
Run Code Online (Sandbox Code Playgroud)
现在,我如何将此路径中的图像加载到UIImage对象?
这是代码:
NSString *path = [occasion imagePath];
//temp
NSLog(@"the 2nd occasion imagePath is: %@", path);
//end
if (path != nil)
{
//UIImage *image = [UIImage imageNamed:path];
UIImage *image = [UIImage imageWithContentsOfFile:path];
image = [image imageByScalingAndCroppingForSize:CGSizeMake(36.0, 42.0)];
[[cell imageView] setImage:image];
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的应用程序使用阿拉伯语描述和元数据.在iTunes中,它表示这些数据必须是英文的,所以我确实用英文写了.然后我找到了本地化功能,但发现它不支持阿拉伯语.
然而,我发现许多应用程序在沙特阿拉伯应用程序商店的名称,元数据和描述中使用阿拉伯语.我想知道该怎么做?
我在通知回来之后尝试更改按钮的标题,但它根本没有响应.我检查了它不是零并检查我分配的文本,一切都很好.我做了属性类型strong而不是weak成功.
- (void) setButtonTitleFromSelectedSearchResult:(NSNotification *)notif
{
[self popController];
self.sourceMapItem = [[notif userInfo] valueForKey:@"SelectedResult"];
NSLog(@"The Selected Result is: %@", self.sourceMapItem.name);
//Testing
NSLog(@"%@", self.fromButton); // check it's not nil
[self.fromButton setTitle:self.sourceMapItem.name];
}
Run Code Online (Sandbox Code Playgroud) 我有一个名为Occasion的自定义对象,定义如下:
#import <Foundation/Foundation.h>
@interface Occasion : NSObject {
NSString *_title;
NSDate *_date;
NSString *_imagePath;
}
@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSDate *date;
@property (nonatomic, retain) NSString *imagePath;
Run Code Online (Sandbox Code Playgroud)
现在我有一个NSMutableArray of Occasions,我想保存到NSUserDefaults.我知道这是不可能的,所以我想知道哪种方法最简单?如果序列化是答案,那么如何?因为我阅读了文档但却无法理解它的完整工作方式.
iphone serialization custom-object nsuserdefaults nsmutablearray
当我在iPhone上运行我的iOS 6应用程序时,我在控制台中收到了这个奇怪的消息.
Webcore NSBeep()
Run Code Online (Sandbox Code Playgroud)
我在其他帖子中读到这个NSBeep甚至不存在于iOS中.除了我在我的应用程序中根本不使用与网络相关的任何内容.那是什么意思呢?这是我应该担心的错误吗?
我正在尝试使用该fitBounds方法在谷歌地图相机视图中拟合我的所有标记.所以我存储了我的标记,markersArray并使用以下代码初始化GMSCoordinateBounds,其中第一和第二标记markersArray工作正常.
然后,当我试图从添加第三个标志markersArray使用includingCoordinate我没有看到边界在它的价值既不是更新任何东西,也不在地图它相应地改变相机.
奇怪的是,在谷歌地图SDK for iOS文档中,它说GMSCoordinateBounds"是不可变的,在构建后无法修改." 那有意义吗?构建它们后我无法改变界限?那么如何在边界上添加更多坐标?
这是我的代码:
GMSCoordinateBounds *bounds= [[GMSCoordinateBounds alloc] init];
GMSMarker *marker1 = [markersArray objectAtIndex:0];
GMSMarker *marker2 = [markersArray objectAtIndex:1];
GMSMarker *marker3 = [markersArray objectAtIndex:2];
bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:marker1.position coordinate:marker2.position];
//Add the 3rd marker to the bounds
[bounds includingCoordinate:marker3.position];
GMSCameraUpdate *update = [GMSCameraUpdate fitBounds:bounds withPadding:600.0f];
[mapView_ animateWithCameraUpdate:update];
Run Code Online (Sandbox Code Playgroud)