UIActionSheet' was displaying properly in my one of the application until iOS 7 release. But now when I open UIActionSheet in iOS 7, it shows black line` on top corner of action sheet. As you can see in below image
After spending ample amount of time to find its reason, Finally I found that if we display UIActionSheet title (set title property with some text) then those black line removed by iOS 7. like image
But As per requirement I don't want to display UIActionSheet title. So Is there any other approach to remove those black lines in corner? Or its an iOS 7 bug?
- (IBAction) showActionsheetWithoutTitle:(id)sender {
UIActionSheet *actionsheet = [[UIActionSheet alloc] initWithTitle:#"" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"Button1", #"Button2",#"Button3", nil];
[actionsheet showInView:self.view];}
Replace #"" with nil for initWithTitle, as it takes a small gap between the title and other buttons:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:#"Button1", #"Button2",#"Button3", nil];
Related
I am looking to add to my iOS app a control that looks like this menu on the bottom:
Can anybody tell me what control that is? Does not look like Picker View.
That is a UIActionSheet. Official Documentation
It cannot be dragged in from the list of UI elements. It is presented programmatically very similar to a UIAlertView.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"Title"
delegate:self cancelButtonTitle:#"Cancel Button"
destructiveButtonTitle:#"Destructive Button"
otherButtonTitles:#"Other Button 1", #"Other Button 2", nil];
[actionSheet show];
I have the following view hierarchy
MMDrawerViewController
--UINavigationController (CenterViewController)
-----UITableViewController (RootViewController for UINavigationViewController)
---------UIToolbar with 1 barButtonItem
--UIViewController (LeftSideViewController)
Now when the button item is selected, a UIActionSheet is shown. This works perfectly fine when I just run the app and select the barButtonItem. But if I select another option, which present modals another view controller followed by dismissing the view controller, now if I select the barButtonItem, the background of the UIActionSheet is misplaced.
Kindly check the attached image.
Any help would be highly appreciated.
Update
This is how I show the UIActionSheet
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:#"" delegate:self cancelButtonTitle:#"Cancel" destructiveButtonTitle:nil otherButtonTitles:#"Upload", #"Create Folder", #"Create File", nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
[actionSheet showFromToolbar:self.navigationController.toolbar];
I'm creating an UIActionSheet:
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:#"Choose region/city"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil, nil];
for (Cities *c in self.cities) {
[actionSheet addButtonWithTitle:c.name];
}
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheet showInView:self.view];
I'm just setting the cities names as the buttontitle. The Cities array length is 8.
The output is fine, but when I click on the first Button ( this one is called Auckland) it says it is a CancelButton.
The other buttons and the cancelbutton works fine, only the first one not. Both the Auckland button and the CancelButton got a buttonIndex of 0.
Can anyone tell me why this is? And how to fix it?
PS:
If i do cancelButtonTitle:nil, its working fine. But i would like the Cancel button:)
alert = [[UIAlertView alloc] initWithTitle:#"Enter Student Name" message:#"" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Save", #"Save and Add", nil];
alert.tag = 1;
alert.alertViewStyle=UIAlertViewStylePlainTextInput;
[alert show];
its been working beautifully in potrait mode but in landscape my UITextfield going out of screen.and now i want to move a alertView frame a little bit down so that it will be visible .
Unfortunately you can't change any thing in the UIAlertView design in iOS7, you should use it as is, you have three chices here:
Take off the cancel button (If i were you i would do this).
Use a custom UIAlertView from cocoacontrols.com and put the three buttons at the same line.
Use another control like popover or modal.
My iOS7 app has an odd visual bug in a UIActionSheet. It is shown below. Any thoughts?
Code:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:#"Done" destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet showInView:self.view];
Looks like an iOS7 bug to me in drawing of the button layer, can't really think of a solution but aside trying to work out the factors that have caused that to happen
Maybe try a different approach and see if you have some success?
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet addButtonWithTitle:#"Done"];
[actionSheet showInView:self.view];
Or maybe set it under otherButtonTitles?
It's a strange one but if you can find the cause it might be worth submitting the bug report to apple