dialog Box in iphone

Discussion in 'iOS Programming' started by ilx.mac, Apr 17, 2009.

  1. macrumors member

    Mar 10, 2009
    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!
  2. macrumors 68000

    Feb 12, 2008
    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(NSDocumentDirectoryNSUserDomainMaskYES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    Will get you the path to the documents directory (which is empty unless you put stuff in it).
  3. macrumors regular

    Apr 9, 2009
    no access to anything but the applications folder, would be WAY too much of a security risk.
  4. thread starter macrumors member

    Mar 10, 2009
    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!
  5. Moderator emeritus


    Jul 24, 2002
    What file dialog box? Where have you seen this used?
  6. thread starter macrumors member

    Mar 10, 2009
    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.
  7. macrumors 68000

    Nov 3, 2007
    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.
  8. macrumors 68030


    Sep 2, 2008
    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.
  9. thread starter macrumors member

    Mar 10, 2009
  10. macrumors newbie

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

    Thanks in Advance,
  11. thread starter macrumors member

    Mar 10, 2009
    Are you looking to show your images folder or some other?
  12. macrumors newbie

    Jun 5, 2009
    Thanks for your response, Yes i am looking for both
    i need to browse and upload photos and other files also .
  13. thread starter macrumors member

    Mar 10, 2009
    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?"
    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.

Share This Page