How to open a dialog box in iphone?
I want to open the dialog box when the user clicks on a browse button in the nib. This would search for a picture he wants from his pc and upload it. How do I do this programmatica开发者_如何学Golly in iphone.
I'm not sure if I understand exactly what you want. But if you just want to show view on top of another view you should user the - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated
method of the UIViewController
.
When pressing the button you init a new UIViewController subclass that does what you wan't to do in this 'popup'. Then you present it to your current view controller by calling the presentModal... method. When you're finished you can call - (void)dismissModalViewControllerAnimated:(BOOL)animated
on your 'popup' view controller to dismiss it.
I think i understand ur problem,if u want to have something like dilogBox in iPhone, then i have something for U. the are two links for .h and .m file. FileChooserAlert.h and FilechooserAlert.m.After clicking on these two links u'll get required files.Now to implement define ur class like this.
FileChooserAlert* fileChooserAlert = [[FileChooserAlert alloc] initWithTitle:@"Select" message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",nil];
[fileChooserAlert show];
[fileChooserAlert release];
The two source file has something that u need to change before u can actually run it.Like there are three images named "File_icon.png","Folder_icon.png","Folder_up.png", which u need to include into ur project.
Now when user selects any file by selecting the tableView Cell and tapping OK button, U can get the file location by calling.
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag == ALERT_TYPE_FILE_CHOOSER)
{
switch (buttonIndex)
{
case 0: //Cancel
break;
case 1:
{
myFileLocation = [(FileChooserAlert*)alertView getFileCompletePath]];
}break;
default:
break;
}
}
}
If U have any problem implementing this file email me.
精彩评论