我无法搞清楚NSBundle和DocumentDirectory数据,我有一个相机图片" imageView ",我正在保存NSDocumentDirectoy,然后想要检索它附加到电子邮件,
这里有保存代码:
- (IBAction)saveImage {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"];
UIImage *image = imageView.image; // imageView is my image from camera
NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:savedImagePath atomically:NO];
}
Run Code Online (Sandbox Code Playgroud)
这是新的获取数据代码:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *appFile = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"];
NSData *myData = [[[NSData alloc] initWithContentsOfFile:appFile] autorelease];
[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"savedImage"];
Run Code Online (Sandbox Code Playgroud) 我一直无法理解这个问题.如果我更改变量名称fifthViewController,则错误消失,但视图控制器不会加载.
丢失.再一次,它可能很简单.
提前致谢.
这是代码:
{
FifthViewController *fifthViewController = [[FifthViewController alloc] initWithNibName:@"FifthView" bundle:nil];
fifthViewController.transactionID = transactionID;
[self.navigationController pushViewController:fifthViewController animated:NO];
[fifthViewController release];
}
Run Code Online (Sandbox Code Playgroud) 我想创建一个NSSagedObject与NsDictionary的内容.和Visa Versa.
我有一个带有对象和键的NSDictionary,它从MYSQL数据库引入并存储到documents目录中.我找不到编辑字典的好信息,所以我想我会尝试NSManaged Object.
如果Object属性发生了变化,我希望能够反转该过程并将对象发回.
找到这个例子的任何帮助都会很棒.
谢谢,
迈克尔
我已经按照以下教程,在模拟器中它工作得很好,但是在我的手机上选择地址时,谷歌地图发布,我想我已经炒了我的大脑.我将它与NavBarContolloer结合使用任何帮助都会很棒.
摘自:Cocoa Touch教程:在iPhone OS上提取地址簿地址值
这是代码:
#import "RootViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "FourthViewController.h"
@implementation ThirdViewController
@synthesize fourthViewController;
@synthesize firstName;
@synthesize lastName;
@synthesize addressLabel;
-(IBAction)switchPage:(id)sender
{
if(self.fourthViewController == nil)
{
FourthViewController *fourthView = [[FourthViewController alloc]
initWithNibName:@"FourthView" bundle:[NSBundle mainBundle]];
self.fourthViewController = fourthView;
[fourthView release];
}
[self.navigationController pushViewController:self.fourthViewController animated:YES];
}
-(IBAction)getContact {
// creating the picker
ABPeoplePickerNavigationController *picker = [[ABPeoplePickerNavigationController alloc] init];
// place the delegate of the picker to the controll
picker.peoplePickerDelegate = self;
// showing the picker
[self presentModalViewController:picker animated:YES];
// …Run Code Online (Sandbox Code Playgroud) 我有一个想要访问Amazon.com的UIwebview,当我加载amazon.com时,它的格式与我从iphone safari那里去的格式不同.什么告诉像amamzon这样的网站重绘iphone?这是我的代码:
- (void)viewDidLoad {
NSString *urlAddress = @"http://www.amazon.com/Inventive-Gadgets-Inc-PQFan-Professionally/dp/B000V8ASR6";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
}
- (IBAction) gotofourth{
[self dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒.
谢谢