Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 299 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to hide title/message frame in a UIAlertController?

#1
When using a `UIAlertController`, if I want to present a `UIActionSheet` with an empty title and an empty message, the frame for the expected placement of the title and/or message remains.

How do I change this so that I only present an `ActionSheet` that reads:
<br>
<br>
Settings
<br>
Sign out
<br>
Cancel
?

Thanks!

![UIAlertController example][1]


[1]:
Reply

#2
if you want to remove Alert controller top area space. Add Alert controller height


let height:NSLayoutConstraint = NSLayoutConstraint(item: alert.view, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: 100)
alert.view.addConstraint(height);

[enter image description here][1]


[1]:
Reply

#3
**Update Swift 4:**

let alert = UIAlertController(title: nil, message: nil, preferredStyle: UIAlertControllerStyle.actionSheet)

Just need to pass `nil` to `title` and `message` params.
Reply

#4
In swift 2.2, you can use code below and I have also changed the color of signout action button



let actionSheet: UIAlertController = UIAlertController(title: nil, message: nil, preferredStyle: .ActionSheet)

self.presentViewController(actionSheet, animated: true, completion: nil)

let settingsActionButton: UIAlertAction = UIAlertAction(title: "Settings", style: .Cancel) { action -> Void in
print("Settings Tapped")
}

reportActionSheet.addAction(settingsActionButton)

let signOutActionButton: UIAlertAction = UIAlertAction(title: "Signout", style: .Default)
{ action -> Void in
//Clear All Method
print("Signout Tapped")

}

signOutActionButton.setValue(UIColor.redColor(), forKey: "titleTextColor")

actionSheet.addAction(signOutActionButton)

let cancelActionButton: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
print("Cancel Tapped")
}

reportActionSheet.addAction(cancelActionButton)
Reply

#5
If you want to change in run time depending on a certain case just write:

`actionController.title = nil`
`actionController.message = nil`
Reply

#6
UIAlertController *controller=[UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleAlert];//style check


UIAlertAction *first = [UIAlertAction actionWithTitle: @"Login with Facebook" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action)
{
//write to perform action

}];


[controller addAction: first];



UIAlertAction *second = [UIAlertAction actionWithTitle: @"Guest User" style: UIAlertActionStyleDefault handler:^(UIAlertAction *action)

{
//write to perform action

}];

[controller addAction:second];


UIAlertAction *third=[UIAlertAction actionWithTitle:@"Registered User" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action)


{
//write to perform action

}];

[controller addAction:third];

[self presentViewController: controller animated: YES completion: nil];
Reply

#7
When I create a UIAlertController with this code I don't have the title spacing.

[UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];

Are you passing in nil for the title and message or empty strings?
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through