PDA

View Full Version : dialog Box in iphone




ilx.mac
Apr 17, 2009, 08:00 AM
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
Apr 17, 2009, 09:35 AM
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,

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
Apr 17, 2009, 09:37 AM
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
Apr 18, 2009, 02:15 AM
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!

robbieduncan
Apr 18, 2009, 02:17 AM
Is there a way to open the file dialog box of the iphone through iphone sdk code development?

What file dialog box? Where have you seen this used?

ilx.mac
Apr 18, 2009, 03:39 AM
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
Apr 18, 2009, 09:01 AM
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
Apr 18, 2009, 10:44 AM
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.

ilx.mac
Apr 20, 2009, 07:16 AM
Thanks for the inputs guys. While googling I found:
http://developer.apple.com/samplecode/NSOperationSample/index.html#//apple_ref/doc/uid/DTS10004184

This is an example for NSDirectoryEnumerator on cocoa.

Is there some thing similar for iphone? Any suggestions guys?

bhanuigame
Jun 5, 2009, 06:04 PM
Even i am looking for the exact requirement,
Anyone please provide me a solution.

Thanks in Advance,
BP

ilx.mac
Jun 8, 2009, 01:58 AM
Even i am looking for the exact requirement,
Anyone please provide me a solution.

Thanks in Advance,
BP

Are you looking to show your images folder or some other?

bhanuigame
Jun 8, 2009, 11:51 AM
Thanks for your response, Yes i am looking for both
i need to browse and upload photos and other files also .
BP

ilx.mac
Jun 9, 2009, 04:54 AM
The following are the delegate methods.


- (void) addPicture:(id)sender {
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
[[[UIAlertView alloc] initWithTitle:@"JumpForward"
message:@"Do you want to use an existing picture or take a picture with the camera?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"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:@"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.