9

I want to create a custom popup window for iPhone which should look like this: enter image description here

What is the most correct way to implement this for iPhone and iPod devices?

MainstreamDeveloper00
  • 8,436
  • 15
  • 56
  • 102
  • 2
    i think the philosophy with iOS is to use action sheets instead of popups like that (for iPhone not iPad). there isnt a built in popup like that for iPhone as far as i know. – Fonix Jul 17 '13 at 11:30
  • @Fonix in case iPhone your right but for iPad we have UIPopoverView to achieve this. – Suryakant Sharma Jul 17 '13 at 11:54
  • yep, i did word my comment to explicitly mention that :P – Fonix Jul 17 '13 at 11:56

5 Answers5

11

The best way to do this is using a UIActionSheet. The code is here:

UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Share" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Facebook",@"Twitter", nil];
[actionSheet showInView:self.view];

A UIActionSheet comes from the bottom to the top with a certain number of buttons you wish to display. You can also put a cancel button that will automatically dismiss the UIActionSheet.

Here is how it will look like:

enter image description here

Abdullah Shafique
  • 6,878
  • 8
  • 35
  • 70
  • Thanks!! but you forgot to mention to add the to the class header, so you don't get a warning: 'Sending ##viewController *const__strong' to parameter of incompatible type 'id' – Aviram Netanel Mar 20 '14 at 10:33
  • `UIActionSheet` is now deprecated. Use `UIAlertController` now. See http://stackoverflow.com/a/32295641/3681880 – Suragch Aug 30 '15 at 10:51
8

You should try third party classes for custom popup windows. Some of are as follow

1.) CMPopTipView
2.) KBPopupBubble
3.) ADPopupView

Bhavin_m
  • 2,746
  • 3
  • 30
  • 49
6

Used third party control, to do this.

Here is the Link you may download this project.

Irfan
  • 4,301
  • 6
  • 29
  • 46
Jitendra
  • 5,055
  • 2
  • 22
  • 42
5

There are many way available. I would do this code personally:

// create view popup
UIView *viewPopup = [[UIView alloc] initWithFrame:CGRectMake(x, y, width, height)];
[self.view addSubview:viewPopup];

// create Image View with image back (your blue cloud)
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, width, height)];
UIImage *image =  [UIImage imageNamed:[NSString stringWithFormat:@"myImage.png"]];
[imageView setImage:image];
[viewPopup addSubview:imageView];

// create button into viewPopup
UIButton *buttonTakePhoto = [[UIButton alloc] initWithFrame:CGRectMake(x, y, width, height)];
[viewPopup addSubview: buttonTakePhoto];
[buttonTakePhoto setTitle:@"Take Photo" forState:UIControlStateNormal];
[buttonTakePhoto addTarget:self action:@selector(actionTakePhoto) forControlEvents:UIControlEventTouchDown];
[viewPopup addSubview:buttonTakePhoto];

You can animated the Alpha viewPopup when click on the Icon Camera such as enable/disable the viewPopup.

Alessandro Pirovano
  • 2,509
  • 28
  • 21
1

The easiest way to implement what you are asking would be to create a view that looks how you want and contains the appropriate UIButtons and then add it as a subview (and animating it's appearance how you want) when the camera button is pressed. Although the comment on your question from Fonix is correct in that action sheets are designed to be used for this purpose on iOS.