UIViewController presents a UINavigationController - no Nav Bar? - cocoa-touch

I have an UIViewController with a table in it. Tapping a blue disclosure icon makes the view controller present a UINavigationController. This works fine and does make the navigation controller show up, but without a navigation bar, as below:
How would I go about making that magical Navbar showing up again? I really need it to present a map in the nav controller, and right now, that does not work.
EDIT: Here's the code I use to show it:
// scanned recently table view thing
- (void)tableView:(UITableView *)tableVieww didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableVieww deselectRowAtIndexPath:indexPath animated:YES];
if(indexPath.section == 0) {
NSString *info = [[scannedBackups objectAtIndex:indexPath.row] objectForKey:#"data"];
NSArray *items = [info componentsSeparatedByString:#"&"];
scanCodeViewCohntroller.dict = [[NSMutableDictionary alloc] init];
int o;
for (o = 0; o < [items count]; o++) {
NSArray *secondItems = [[items objectAtIndex:o] componentsSeparatedByString:#"="];
[scanCodeViewCohntroller.dict setObject:[secondItems objectAtIndex:1] forKey:[secondItems objectAtIndex:0]];
}
/*NSError *err;
scanCodeViewCohntroller.dict = [NSPropertyListSerialization propertyListWithData:[foo dataUsingEncoding:NSUnicodeStringEncoding] options:NSPropertyListMutableContainersAndLeaves format:kCFPropertyListXMLFormat_v1_0 error:&err];
if(err != nil) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Corrupted Data" message:[NSString stringWithFormat:#"Your Scanned Backup Data Store is corrupted. It will now be erased. %#", [err localizedDescription]] delegate:nil cancelButtonTitle:#"Dismiss" otherButtonTitles:nil];
[alert show];
[alert release];
scannedBackups = [[NSMutableArray alloc] init];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fullFileName = [NSString stringWithFormat:#"%#/scannedCodes.plist", documentsDirectory];
[scannedBackups writeToFile:fullFileName atomically:NO];
[tableView reloadData];
}*/
[scanCodeViewCohntroller.dict setObject:[[scannedBackups objectAtIndex:indexPath.row] objectForKey:#"date"] forKey:#"date"];
[scanCodeViewCohntroller initalizeData];
[self presentModalViewController:scanCodeViewCohntroller animated:YES];
}
}

You need to get the navigation controller and invoke setNavigationBarHidden:animated:. So, try:
[detailController.navigationController setNavigationBarHidden:NO animated:NO];
Edit:
Based on your edit, I would suggest replacing the final line:
[self presentModalViewController:scanCodeViewCohntroller animated:YES];
with:
[self.navigationController pushViewController:scanCodeViewCohntroller animated:YES];

Related

Data Written to Plist is not saving

I made a few changes to the plist like inserting,deleting and reordering rows in a table.plist is changing to default on viewDidDisappear.
I tried the following code.
-(NSString *)dataFilePath{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataFile = [documentsDirectory stringByAppendingPathComponent:#"ETCategoryList.plist"];
return dataFile;
}
//Code for deleting.
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle == UITableViewCellEditingStyleDelete){
[[self categoriesArray]removeObjectAtIndex:[indexPath row]];
NSArray *indexPathsToRemove = [NSArray arrayWithObject:indexPath];
[tableView deleteRowsAtIndexPaths:indexPathsToRemove withRowAnimation:UITableViewRowAnimationLeft];
[tableView reloadData];
NSArray *revisedArray = [[NSArray alloc]initWithArray:self.categoriesArray];
[revisedArray writeToFile:[self dataFilePath] atomically:YES];
}
}
Your code is :
NSArray *revisedArray = [[NSArray alloc]initWithArray:self.categoriesArray];
[revisedArray writeToFile:[self dataFilePath] atomically:YES];
which is correct!!!
The problem should be from self.categoriesArray, if the array contains some objects/ custom object then you can not write directly.
You need to archive it to NSData
NSData *objData = [NSKeyedArchiver archivedDataWithRootObject:object];
Or you can endcode it in your Custom Class.
- (void) encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:obj1 forKey:#"key1"];
[encoder encodeFloat:obj2 forKey:#"key2"];
}
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:coder];
obj1 = [coder decodeObjectForKey:#"key1"];
obj2 = [coder decodeObjectForKey:#"key2"];
return self;
}
your code is fine enough. its working well with me.
Sample code:
self.clickMeArray = [[NSMutableArray alloc] init];
for(int i =1; i<10;i++)
{
[self.clickMeArray addObject:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:#"n%d",i] forKey:[NSString stringWithFormat:#"iN%d",i]]];
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataFile = [documentsDirectory stringByAppendingPathComponent:#"MyName.plist"];
[self.clickMeArray writeToFile:dataFile atomically:YES];
try to clean Build and Relaunch.
Try this
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *lefttBtn = [[UIBarButtonItem alloc] initWithTitle:#"Edit" style:UIBarButtonItemStylePlain
target:self action:#selector(EditTable:)];
[[self navigationItem] setLeftBarButtonItem:lefttBtn];
[lefttBtn release];
}
- (void) EditTable:(id)sender
{
if(self.editing)
{
[super setEditing:NO animated:NO];
[table setEditing:NO animated:NO];
[table reloadData];
[self.navigationItem.leftBarButtonItem setTitle:#"Edit"];
[self.navigationItem.leftBarButtonItem setStyle:UIBarButtonItemStylePlain];
}
else
{
[super setEditing:YES animated:YES];
[table setEditing:YES animated:YES];
[table reloadData];
[self.navigationItem.leftBarButtonItem setTitle:#"Done"];
[self.navigationItem.leftBarButtonItem setStyle:UIBarButtonItemStyleDone];
}
}
-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if(editingStyle == UITableViewCellEditingStyleDelete){
[[self categoriesArray]removeObjectAtIndex:indexPath.row];
[[self categoriesArray] writeToFile:[self dataFilePath] atomically:YES];
[tableView reloadData];
}
}

Remove Image From NSMutableArray

So, the app that I'm writing allows the user to upload a photo from their camera roll, and it displays in a UIImageView. I have a "Save" button, that allows the images to be saved when pressed. I also have an "Edit" button, when tapped, it allows the user to tap on the photo and it will be deleted. This is where I'm having issues, the image deletes from the view, but doesn't seem to delete from the array. When I close and relaunch the app, the photo appears again. I'm very new to Objective-C, I'm surprised that I even made it this far, so I'm having issues figuring out how to delete it from the array.
Also, as a side note, if I grab 3 images from the camera roll, delete the middle one, and then press the save button, after closing and relaunching the app it displays only the 2 photos like it should. The issue regarding the image appearing again after relaunch only happens if I press save first, then try and delete them.
This is how I'm deleting them. I have an invisible button over each UIImageView, and when the Edit button is pressed, it unhides them. I've tagged both the buttons and the UIImageViews, and when one of the buttons is pressed, this fires:
- (IBAction)deleteButtonPressed:(id)sender {
UIAlertView *deleteAlertView = [[UIAlertView alloc] initWithTitle:#"Delete"
message:#"Are you sure you want to delete this photo?"
delegate:self
cancelButtonTitle:#"No"
otherButtonTitles:#"Yes", nil];
[deleteAlertView show];
int imageIndex = ((UIButton *)sender).tag;
deleteAlertView.tag = imageIndex;
}
- (UIImageView *)viewForTag:(NSInteger)tag {
UIImageView *found = nil;
for (UIImageView *view in self.array) {
if (tag == view.tag) {
found = view;
break;
}
}
return found;
}
- (void)alertView: (UIAlertView *) alertView
clickedButtonAtIndex: (NSInteger) buttonIndex
{
if (buttonIndex != [alertView cancelButtonIndex]) {
UIImageView *view = [self viewForTag:alertView.tag];
if (view) {
[self.array removeObject:view];
}
((UIImageView *)[self.view viewWithTag:alertView.tag]).image =nil;
}
[self.user setObject:self.array forKey:#"images"];
}
And just for reference, this is how I'm saving the images:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
if (imageView.image == nil) {
imageView.image = img;
[self.array addObject:imageView];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
if (imageView2.image == nil) {
imageView2.image = img;
NSLog(#"The image is a %#", imageView);
[self.array addObject:imageView2];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
...
...
}
-(IBAction)saveButtonPressed:(id)sender {
NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES) objectAtIndex:0];
for (UIImageView *imageViewToSave in self.array) {
NSInteger tag = imageViewToSave.tag;
UIImage *image = imageViewToSave.image;
NSString *imageName = [NSString stringWithFormat:#"Image%i.png",tag];
NSString *imagePath = [docsDir stringByAppendingPathComponent:imageName];
[UIImagePNGRepresentation(image) writeToFile:imagePath atomically:NO];
}
}
And this is how I'm loading them:
-(void)viewDidLoad {
self.array = [NSMutableArray array];
NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];
NSArray *docFiles = [[NSFileManager defaultManager]contentsOfDirectoryAtPath:docsDir error:NULL];
for (NSString *fileName in docFiles) {
if ([fileName hasSuffix:#".png"]) {
NSString *fullPath = [docsDir stringByAppendingPathComponent:fileName];
UIImage *loadedImage = [UIImage imageWithContentsOfFile:fullPath];
if (!imageView.image) {
imageView.image = loadedImage;
}
else if (!imageView2.image) {
imageView2.image = loadedImage;
}
else if (!imageView3.image) {
imageView3.image = loadedImage;
}
}
}
}
Update: Here is my current code:
- (IBAction)deleteButtonPressed:(id)sender {
NSLog(#"Sender is %#", sender);
UIAlertView *deleteAlertView = [[UIAlertView alloc] initWithTitle:#"Delete"
message:#"Are you sure you want to delete this photo?"
delegate:self
cancelButtonTitle:#"No"
otherButtonTitles:#"Yes", nil];
[deleteAlertView show];
int imageIndex = ((UIButton *)sender).tag;
deleteAlertView.tag = imageIndex;
}
- (UIImageView *)viewForTag:(NSInteger)tag {
UIImageView *found = nil;
for (UIImageView *view in self.array) {
if (tag == view.tag) {
found = view;
break;
}
}
return found;
}
- (void)alertView: (UIAlertView *) alertView
clickedButtonAtIndex: (NSInteger) buttonIndex
{
if (buttonIndex != [alertView cancelButtonIndex]) {
UIImageView *view = [self viewForTag:alertView.tag];
if (view) {
[self.array removeObject:view];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:#"Image%i.png",view.tag]];
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:filePath error:NULL];
}
((UIImageView *)[self.view viewWithTag:alertView.tag]).image =nil;
}
[self.user setObject:self.array forKey:#"images"];
}
When you're deleting the image from the array [self.array removeObject:view];, you haven't removed the image itself from the directory.
You may want to do something like this after removing the object from array:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *filePath = [documentsPath stringByAppendingPathComponent:#"THE_IMAGE_NAME_HERE.png"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
[fileManager removeItemAtPath:filePath error:&error];
if (error)
NSLog(#"Error: %#",error);
Your array has nothing to do with this. It is overwritten on the next launch anyway. I don't think you are ever deleting your image from the folder, so it is read again on the next launch in your viewDidLoad method.

iOS SDK, Objective-C, uitable only showing one cell

I have a textfield that the user inputs, then I save it with NSKeyedArchiver and pull it out to view on the table but every time I enter something in the textfield and save it, it replaces the first item in the cell, I want it to add it to the table.
in NewEntry.m where I save the data with
- (IBAction)saveButton:(id)sender {
int i = selectedSegment.selectedSegmentIndex;
app = [[UIApplication sharedApplication] delegate];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setInteger:i forKey:#"category"];
if (i == 0) {
// [userDefaults setObject:titlefield.text forKey: #"titlehomework"];
// [userDefaults setObject:detailstextfield.text forKey:#"detailshomework"];
NSMutableArray *contactArray;
contactArray = [[NSMutableArray alloc] init];
[contactArray addObject:titlefield.text];
[contactArray addObject:detailstextfield.text];
[NSKeyedArchiver archiveRootObject:
contactArray toFile:datafilePath];
}
else if(selectedSegment.selectedSegmentIndex == 1) {
[userDefaults setObject:titlefield.text forKey:#"titletextprojects"];
[userDefaults setObject:detailstextfield.text forKey:#"detailsprojects"];
}
else if (selectedSegment.selectedSegmentIndex == 2){
[userDefaults setObject:titlefield.text forKey:#"titletextappointments"];
[userDefaults setObject:detailstextfield.text forKey:#"detailsappointments"];
}
else if (selectedSegment.selectedSegmentIndex == 3){
[userDefaults setObject:titlefield.text forKey:#"titletextevents"];
[userDefaults setObject:detailstextfield.text forKey:#"detailsevents"];
}
else if (selectedSegment.selectedSegmentIndex == 4){
[userDefaults setObject:titlefield.text forKey:#"titletexttodolist"];
[userDefaults setObject:detailstextfield.text forKey:#"detailstodolist"];
}
/*[userDefaults synchronize];
titlefield.text =#" ";
detailstextfield.text =#" ";
NSLog(#"selected segment %i", i);*/
/* UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Task saved!" message:#"You're all done." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, selectedSegment.selectedSegmentIndex];
[alert show];*/
[[NSNotificationCenter defaultCenter] postNotificationName:#"ValuesChanged"
object:self];
[self dismissModalViewControllerAnimated:YES];
}
NewEntry ViewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
if (__managedObjectContext == nil)
{
__managedObjectContext = [(StaticTableAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSLog(#"After managedObjectContext_: %#", __managedObjectContext);
}
NSFileManager *filemgr;
NSString *docsDir;
NSArray *dirPaths;
filemgr = [NSFileManager defaultManager];
// Get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
// Build the path to the data file
datafilePath = [[NSString alloc] initWithString: [docsDir
stringByAppendingPathComponent: #"data.archive"]];
// Check if the file already exists
if ([filemgr fileExistsAtPath: datafilePath])
{
NSMutableArray *dataArray;
dataArray = [NSKeyedUnarchiver
unarchiveObjectWithFile: datafilePath];
//titlefield.text = [dataArray objectAtIndex:0];
// detailstextfield.text = [dataArray objectAtIndex:1];
}
}
new entry ViewDidUnload:
- (void)viewDidUnload
{
[self setTitleTextfield:nil];
[self setCategory:nil];
[self setDetailstextfield:nil];
[self setTitlefield:nil];
[self setTitlefield:nil];
[self setSelectedSegment:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
And in the table controller I call it here:
tableview:
- (void)viewDidLoad
{
[super viewDidLoad];
// [self fetchRecords];
if(tablesubtitles == nil && tabledata == nil){
tablesubtitles = [[NSMutableArray alloc]init];
tabledata = [[NSMutableArray alloc] init];
}
NSFileManager *filemgr;
NSString *docsDir;
NSArray *dirPaths;
filemgr = [NSFileManager defaultManager];
// Get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
// Build the path to the data file
datafilePath = [[NSString alloc] initWithString: [docsDir
stringByAppendingPathComponent: #"data.archive"]];
// Check if the file already exists
if ([filemgr fileExistsAtPath: datafilePath])
{
NSMutableArray *dataArray;
dataArray = [NSKeyedUnarchiver
unarchiveObjectWithFile: datafilePath];
titlestring = [dataArray objectAtIndex:0 ];
detailsstring = [dataArray objectAtIndex:1];
[tabledata addObject:titlestring];
[tablesubtitles addObject:detailsstring];
}
}
and:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:#"homeworkcell"];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:#"homework"];
}
NSString *cellValue = [tabledata objectAtIndex:indexPath.row];
NSString *subtitle = [tablesubtitles objectAtIndex:indexPath.row];
cell.textLabel.text= cellValue;
cell.detailTextLabel.text= subtitle;
cell.textLabel.font = [UIFont systemFontOfSize:14.0];
cell.textLabel.backgroundColor = [ UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
//[tabledata addObjectser.title];
//[tabledata addObject:user.detai/s];
//static NSString *CellIdentifier = #"Cell";
// Configure the cell.
//-----------------------------------------START----------------------------Set image of cell----
cellImage = [UIImage imageNamed:#"checkboxblank.png"];
cell.imageView.image = cellImage;
//--------------------------------------------END---------------------------end set image of cell--
return cell;
}
*************UPDATE**********
So in saveButton it should be:
NSMutableArray *contactArray;
contactArray = [NSKeyedUnarchiver
unarchiveObjectWithFile: datafilePath];
// contactArray = [[NSMutableArray alloc] init];
[contactArray addObject:titlefield.text];
[contactArray addObject:detailstextfield.text];
[NSKeyedArchiver archiveRootObject:
contactArray toFile:datafilePath];
// NSDictionary *stuff;
?
The problem is that you are creating a new mutable array, putting one item in it, and then archiving that array to your file. This is going to replace whatever was there before.
To add a new item you need to unarchive the array first, add to that array, and then archive your new array.
There seems to be some core data code in here as well, there is little merit in doing your own archiving if you are going to use core data.

multi-section UITableView issues

I have an UITableView that contains 3 NSArrays and 3 NSDictionaries for each array.
- (void)viewDidLoad {
[super viewDidLoad];
contentArray = [[NSMutableArray alloc] init];
self.settingsArray = [NSArray arrayWithObjects:#"Settings", nil];
NSDictionary *settingsDict = [NSDictionary dictionaryWithObject:settingsArray forKey:#"Settings"];
self.infoArray = [NSArray arrayWithObjects: #"Version 1.0", #"© Copyrights 2010", #"Developer Site", #"App Page", #"Report a Bug", nil];
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:infoArray forKey:#"Settings"];
self.contactArray = [NSArray arrayWithObjects: #"Developer Site", #"App Page", #"Report a Bug", nil];
NSDictionary *contactDict = [NSDictionary dictionaryWithObject:contactArray forKey:#"Settings"];
[contentArray addObject:infoDict];
[contentArray addObject:settingsDict];
[contentArray addObject:contactDict];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[infoArray objectAtIndex:indexPath.row] isEqual:#"Version 1.1"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
if ([[infoArray objectAtIndex:indexPath.row] isEqual:#"© Copyrights 2010"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
if ([[settingsArray objectAtIndex:indexPath.row] isEqual:#"Settings"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Title" message:#"NULL" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
}
if ([[contactArray objectAtIndex:indexPath.row] isEqual:#"Developer Site"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
if ([[contactArray objectAtIndex:indexPath.row] isEqual:#"App Page"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
if ([[contactArray objectAtIndex:indexPath.row] isEqual:#"Report a Bug"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
}
The problem is when I'm trying to select a row, the application is crashing
Thanks
That error will occur when you attempt to access an index beyond the bounds of an array. For example, you'll encounter an NSRangeException if your array has only one item and you ask for the object at index 3. The immediate solution is to check the array's size before querying its contents.
NSArray* exampleArray = [NSArray arrayWithObjects:#"One", #"Two", #"Three", nil];
int items = [exampleArray count];
if(indexPath.row < items) {
// do stuff
}

Stack A scroll view onto UIImagePickerController

I'd like to first say I'm a little new to anything but tutorial examples, so sorry if this is a daft question.
I have modified some sample code ever so slightly so that instead of closing a UIImagePickerController once the user has picked an image it processes it in the background.
This seems to work quite well, but once the user has picked all of the images they want to process the only button they're presented with is "Cancel".
I was hoping to change the code so that it adds the selected image to a scrolling view at the bottom of the image picker, but can't find a way to stack or overlay anything onto the UIImagePickerController view.
The code I have so far is below:
-(IBAction)LoadPhotoAlbums:(id)sender
{
NSLog(#"LoadPhotoAlbums");
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
return;
}
if(photoPicker == NULL) {
photoPicker = [[UIImagePickerController alloc] init];
photoPicker.delegate = self;
photoPicker.allowsImageEditing = NO;
}
photoPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:photoPicker animated:YES];
[pool release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
if([[info objectForKey:#"UIImagePickerControllerMediaType"] isEqualToString:K_UI_TYPE_IMAGE])
{
NSLog(#"Image Selected");
selectedImage = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:#"ddMMMyyyyHHmmss"];
NSString *date = [dateFormatter stringFromDate:[NSDate date]];
NSData *imageData = UIImageJPEGRepresentation(selectedImage,0.9);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
selectedImagePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:#"%#.jpg", date]];
NSLog(#"Image path is %#", selectedImagePath);
if([imageData writeToFile:selectedImagePath atomically:YES])
NSLog(#"Write Successful");
}
//[picker dismissModalViewControllerAnimated:YES];
//add to listofimages view.
[self uploadSelectedImage];
}