Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ilx.mac

macrumors member
Original poster
Mar 10, 2009
63
0
I have to open a dialog box & show folders present in the iphone using sdk. Is that possible? If yes, can some one guide me. If no, any other alternates! Please!

Thanks in advance!
 

Niiro13

macrumors 68000
Feb 12, 2008
1,719
0
Illinois
The best you can do is show the folders in the documents directory of the application as the SDK does not allow read/write access to folders outside of it's documents directory.

In that case,

PHP:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory = [paths objectAtIndex:0];

Will get you the path to the documents directory (which is empty unless you put stuff in it).
 

BlackWolf

macrumors regular
Apr 9, 2009
244
0
I have to open a dialog box & show folders present in the iphone using sdk. Is that possible? If yes, can some one guide me. If no, any other alternates! Please!

Thanks in advance!

no access to anything but the applications folder, would be WAY too much of a security risk.
 

ilx.mac

macrumors member
Original poster
Mar 10, 2009
63
0
no access to anything but the applications folder, would be WAY too much of a security risk.

I am trying to upload images from a folder where its stored. for that I need it. Is there a way to open the file dialog box of the iphone through iphone sdk code development?

I tried the earlier one but I failed.

Thanks in Advance!
 

ilx.mac

macrumors member
Original poster
Mar 10, 2009
63
0
I havent seen that in iphone sdk. Its some thing similar to the dialog box which opens in windows XP, while u want to save some file. It will show its root folders & other created folders in it.

Ok let it be. Is there a way to show a folder (of iphone some thing like, videos/audio/themes/...) which has some files in it to the user when a button is clicked.
 

Jeremy1026

macrumors 68020
Nov 3, 2007
2,215
1,029
I havent seen that in iphone sdk. Its some thing similar to the dialog box which opens in windows XP, while u want to save some file. It will show its root folders & other created folders in it.

Ok let it be. Is there a way to show a folder (of iphone some thing like, videos/audio/themes/...) which has some files in it to the user when a button is clicked.

Are you going to keep asking until you get the answer you want? No, you only have access to folders within your application. Such as MyApp/Documents.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
There's no built-in file chooser dialog but you can build one with the SDK that can display the files in your app sandbox. Use NSDirectoryEnumerator to build a list of files in a folder and use UITableView to display files and folders.
 

bhanuigame

macrumors newbie
Jun 5, 2009
2
0
Even i am looking for the exact requirement,
Anyone please provide me a solution.

Thanks in Advance,
BP
 

bhanuigame

macrumors newbie
Jun 5, 2009
2
0
Thanks for your response, Yes i am looking for both
i need to browse and upload photos and other files also .
BP
 

ilx.mac

macrumors member
Original poster
Mar 10, 2009
63
0
The following are the delegate methods.


- (void) addPicture:(id)sender {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[[[UIAlertView alloc] initWithTitle:mad:"JumpForward"
message:mad:"Do you want to use an existing picture or take a picture with the camera?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:mad:"Use Existing", @"Camera", nil] show];
}
[self retrievePicture:UIImagePickerControllerSourceTypePhotoLibrary];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
[self retrievePicture:(buttonIndex == 0 ? UIImagePickerControllerSourceTypePhotoLibrary : UIImagePickerControllerSourceTypeCamera)];
}

- (void) retrievePicture:(UIImagePickerControllerSourceType)type{
UIImagePickerController *picker = [[[UIImagePickerController alloc] init] autorelease];
[picker setDelegate:self];
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self.navigationController presentModalViewController:picker animated:YES];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[self.navigationController dismissModalViewControllerAnimated:YES];
Photo *newPhoto = [[[Photo alloc] init] autorelease];
[newPhoto setImage:image];
[newPhoto setCaption:mad:"Another new photo!"];
[newPhoto setCreateDate:[NSDate date]];

[pictures insertObject:newPhoto atIndex:0];
[self.tableView reloadData];
}


Your .h file should be something similar to this:

@interface EditPicture : UITableViewController <UIAlertViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITextFieldDelegate> {
NSMutableArray *pictures;
}


i hope this helps you to add photos.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.