UIActionsheet Ipad/Iphone - iphone

I'm currently using a UIActionsheet for my universal app, works great and all, but I want the iPad actionsheet to resemble the iPhone actionsheet.
Is there anything on the iPad that is similar to the iPhone actionsheet? Alternatively, is there a way to reposition the iPad actionsheet and popoverview WITHOUT a direction arrow?
Thanks
EDIT: Here is the code where I implement and add the actionsheet
adActionSheet = [[UIActionSheet alloc]initWithTitle:#"Title" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"Go to Site", #"Some other button", nil];
[adActionSheet showFromRect:CGRectMake(300, 1150, 200, 200) inView:self.view animated:YES];

On an iPad, action sheets are automatically shown in a popover. This can't be changed. You can't remove the array either. The UIActionSheet API doesn't support what you want.
Your only solution is a custom implementation that does what you want.

Actually you can remove arrow from UIPopover in ipad
[self.popoverController presentPopoverFromBarButtonItem:anItem
permittedArrowDirections:0
animated:YES];
or
[self.popoverViewController presentPopoverFromRect:rect
inView:self.view permittedArrowDirections:0 animated:YES];
The zero represent no direction.

Related

iPhone, UINavigationController and UITabBar how to present a modal dialog regardless of the selected tab?

I have a UINavigationController and a UITabBar within the application. Each ViewController within the tabbar has its own UINavigationController.
I would like to be able to present a modal dialog to the user (an alert/reminder/legal/join mailing list) kind of action regardless of the currently selected tab.
Right now I have one of my UIViewControllers handle the act of presenting the dialog, but the user would not see it, unless the tab has been selected.
How would I go about solving such a problem? Storyboards come to mind, but my project is far too deep to rewrite it for storyboards in its current state.
Thank you!
You could present it on the UITabBarController.
[tabBarController presentModalViewController:animated:];
...or you can easily subclass UIAlertView/create a category to show a custom modal view when you want, simply calling
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle:#""
message:#""
delegate:nil
cancelButtonTitle:#""
otherButtonTitles:nil];
[alert showCustom]; // <---- FROM CATEGORY
[alert release];
Here an example: http://goo.gl/7jaE8

Adding a UILabel or NSString to UIalertView

I would like to add a bunch of UILabels or NSStrings to the UIALertView since I have run out of space on my display.
UIAlertView *alertDialog;
alertDialog = [[UIAlertView alloc]
initWithTitle:#"random" message:nil delegate:self cancelButtonTitle:#"Dismiss" otherButtonTitles: nil];
//firstString=[[UILabel alloc]initWithFrame: CGRectMake(12.0, 70.0, 260.0, 25.0)];
[alertDialog addSubview:firstString];
[alertDialog show];
[alertDialog release];
I can tell you from experience that this is a bad idea. In earlier version or iOS there were tricks using undocumented behavior, Apple made changes to the underlaying code and it all broke badly. Just create a UIView the way you like. If you want to dim the rest of the screen just place a semi-transparenr view over the screen and under your view.
You can use a alternative implementation of an alert view. One, that is not a subclass of UIAlertView — so it is absolutely independent to any changes Apple may release. And you have the possibility to add any subview as a clean property.
TSAlertView is such an alternative implementation.
you can use uitextfield to do so ,
simply change textcolor to while , and change background color to clearColor

UIActionsheet in the middle of the screen

I want to show a UIActionSheet in the middle of the screen.I tried with the following code
UIView *placeholderview=[[UIView alloc]initWithFrame:CGRectMake(0, 310, 320, 100)];
[self.view addSubview:placeholderview];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"Open File",#"Save FIle",#"New File",#"Export Image",nil];
[actionSheet showFromRect:CGRectMake(0,0, 320, 10) inView:placeholderview animated:YES];
[actionSheet release];
I get the result as desired but i can click only cancel button, and the half of export image button.I don't know where i am going wrong.Kindly please any body help me.What should i do to make it working.
UIActionSheet is designed to be presented from the bottom of the screen.
It provides methods for presenting from a toolbar or tab bar in cases where those UI elements may cause obstruction.
Why are you wanting to show the action sheet in the middle of the screen. I wouldn't recommend this because it looks wrong, and isn't the designed behaviour of the control.
The method you are currently using is for iPad - it shouldn't be used on iPhone, as it causes undefined behaviour (as you are experiencing).
UIActionSheet's showFromRect:inView:animated: method is only supposed to be used on iPad. Its behavior on iPhone is undefined.

How do I get those small views from the bottom to appear in iOS SDK?

I'n talking about the small windows with buttons that come from the bottom when you need to confirm some action. For example, if you want to delete a photo from an album and press the trash icon, a small view jumps from the bottom and asks if you want to delete the photo or cancel
How do I get those views to appear?
Use a UIActionSheet.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"Some Action"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:#"OK"
otherButtonTitles: nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
[actionSheet release];
You'll want to look at the UIActionSheet object: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIActionSheet_Class/Reference/Reference.html
An example here: http://ykyuen.wordpress.com/2010/04/14/iphone-uiactionsheet-example/

Change the color of a button on a standard pop-up action

I am using a standard pop up action in my iphone app (the pop up at the bottom of the screen). This has 2 buttons "ok" and "cancel". It seems the standard colour scheme is to have the top button red. I want to change this so the top button is green. I have been googling forever and can't find the solution. Any ideas would be great. Thanks
You can browse through ActionSheet ( I assume you use UIActionSheet class) subviews - like that:
NSArray* subViews = [aSheet subviews];
for (UIView* sView in subViews)
{
...
}
And change subviews properties there as you like.
You can also create UIActionSheet without any buttons at all:
UIActionSheet* aSheet = [[UIActionSheet alloc] initWithTitle:#"\n\n\n" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
And afterward create your own custom buttons and add them to the ActionSheet view. (put more \n to the title to enlarge Sheet height)
I assume you're referring to a UIActionSheet. In a UIActionSheet, you can define a button that cancels the action and has a black background, a button that marks a destructive action and has a red background, and all other buttons which have white backgrounds. Which option corresponds to which class of actions can be specified in the initialization of the UIActionSheet using – initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:.
The design of a UIActionSheet, including why you should only use these colors for your buttons, is explained in the iPhone Human Interface Guidelines. I'd follow Apple's suggestions in this regard, as they will make your application easier to use.
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:#""
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil,#"Mail",#"Facebook",#"Twitter",nil
otherButtonTitles:nil];
NSArray *buttons = [action subviews];