dialog Box in iphone

Discussion in 'iPhone/iPad Programming' started by ilx.mac, Apr 17, 2009.

  1. macrumors member

    Joined:
    Mar 10, 2009
    #1
    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

    Joined:
    Feb 12, 2008
    Location:
    Illinois
    #2
    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(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

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

    Joined:
    Mar 10, 2009
    #4
    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

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #5
    What file dialog box? Where have you seen this used?
     
  6. thread starter macrumors member

    Joined:
    Mar 10, 2009
    #6
    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

    Joined:
    Nov 3, 2007
    #7
    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

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #8
    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

    Joined:
    Mar 10, 2009
    #9
  10. macrumors newbie

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

    Thanks in Advance,
    BP
     
  11. thread starter macrumors member

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

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

    Joined:
    Mar 10, 2009
    #13
    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.
     

Share This Page