How can I Add TextField & CheckBox into the same AlertView - ios

I've added CheckBox into AlertView now I'd like to add TextField too into the same AlertView.
UIAlertView *alertForExistingCredit = [[UIAlertView alloc] init];
rememberButton = [[UIButton alloc] init];
UIView *v = [[UIView alloc] init];
[rememberButton setImage:[UIImage imageNamed:#"PortraitPhoto_Checkbox-Normal.png"]
forState:UIControlStateNormal];
[rememberButton setTitle:#"Save Code" forState:UIControlStateNormal];
[rememberButton addTarget:self action:#selector(toggleRememberMethod) forControlEvents:UIControlEventTouchUpInside];
alertForExistingCredit = [[UIAlertView alloc] initWithTitle:#"PrePay Code"
message:#""
delegate:self
cancelButtonTitle:kCancelMessage
otherButtonTitles:kAlertOkMessage, nil];
[v addSubview:rememberButton];
If I use:
//plain text part
// alertForExistingCredit.alertViewStyle = UIAlertViewStylePlainTextInput;
// [[alertForExistingCredit textFieldAtIndex:0] setPlaceholder:#"PrePay Code"]; this lines of code it is not showing on the screen
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
v.frame = CGRectMake(0, 0, 250, 40);
rememberButton.frame = CGRectMake(0.0, 0, 250, 50.0);
[rememberButton setTitleColor:[UIColor blackColor]
forState:UIControlStateNormal];
alertForExistingCredit.message = #"Please insert your PrePay code";
[alertForExistingCredit setValue:v forKey:#"accessoryView"]
}else {
v.frame = CGRectMake(0, 80, 250, 40);
rememberButton.frame = CGRectMake(0.0, 0, 250, 40.0);
alertForExistingCredit.message = #"Please insert your PrePay code";
[alertForExistingCredit addSubview:v];
}
alertForExistingCredit.tag = 0;
[alertForExistingCredit show];
}

Try to add this UITextField to your v (UIView), and try to adjust frame size and location.
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 50, 250, 50)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.font = [UIFont systemFontOfSize:15];
textField.placeholder = #"enter text";
textField.autocorrectionType = UITextAutocorrectionTypeNo;
textField.keyboardType = UIKeyboardTypeDefault;
textField.returnKeyType = UIReturnKeyDone;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textField.delegate = self;
[v addSubview:textField];

Add add a subview into your UIAlertView and put your buttons into that view, see the code to add a UIView into your UIAlertView
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"TEST" message:#"subview" delegate:nil cancelButtonTitle:#"NO" otherButtonTitles:#"YES", nil];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
[alert setValue:view forKey:#"accessoryView"];
// add your button in *view*.
[alert show];

Related

UIAlertController is not is window hierarchy

Im trying to show up a pop up containing a UIPickerView and UITextField.
Following is my code that I use to create the pop up.
self.alert = [UIAlertController alertControllerWithTitle:nil message:#"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" preferredStyle:UIAlertControllerStyleAlert];
CGRect pickerFrame = CGRectMake(0, 0, 270, 200);
UIPickerView *regionsPicker = [[UIPickerView alloc] initWithFrame:pickerFrame];
regionsPicker.tag = 1;
regionsPicker.dataSource = (id <UIPickerViewDataSource>)self;
regionsPicker.delegate = (id <UIPickerViewDelegate>) self;
[regionsPicker setShowsSelectionIndicator:YES];
UIView *toolView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 270.0f, 44.f)];
toolView.backgroundColor = [UIColor blackColor];
CGRect buttonFrame = CGRectMake(0, 5, 100, 30);
UIButton *button = [[UIButton alloc] initWithFrame: buttonFrame];
button.imageEdgeInsets = UIEdgeInsetsMake(0, button.titleLabel.frame.size.width, 0, -button.titleLabel.frame.size.width);
UIImage *btnImage = [UIImage imageNamed:#"delete.png"];
[button setImage:btnImage forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button setTitleColor: [UIColor blueColor] forState: UIControlStateNormal];
[toolView addSubview:button];
[button addTarget:self action:#selector(closeDialog:) forControlEvents:UIControlEventTouchUpInside];
self.textField = [[UITextView alloc] initWithFrame:CGRectMake(30, 170, 220, 200)];
_textField.editable = NO;
_textField.hidden=true;
self.textField.text = #"Enter text...";
self.textField.font = [UIFont systemFontOfSize:15];
self.textField.autocorrectionType = UITextAutocorrectionTypeNo;
self.textField.keyboardType = UIKeyboardTypeDefault;
self.textField.returnKeyType = UIReturnKeyDone;
self.textField.textColor = [UIColor lightGrayColor];
self.textField.delegate = (id <UITextViewDelegate>) self;
self.textField.layer.borderWidth = 1.0f;
self.textField.layer.cornerRadius = 5;
self.textField.layer.borderColor = [[UIColor grayColor] CGColor];
[toolView addSubview:self.textField];
CGRect actionFrame = CGRectMake(80, 400, 100, 30);
UIButton *actionBtn = [[UIButton alloc] initWithFrame: actionFrame];
[actionBtn setTitle:#"Submit" forState:UIControlStateNormal];
[actionBtn setTitleColor: [UIColor whiteColor] forState: UIControlStateNormal];
[actionBtn setBackgroundColor:[UIColor purpleColor]];
[self.textField setUserInteractionEnabled:YES];
[toolView setUserInteractionEnabled:YES];
[self.alert.view setUserInteractionEnabled:YES];
[self.alert.view addSubview:regionsPicker];
[self.alert.view addSubview:self.textField];
[self.alert.view addSubview:toolView];
[self.alert.view addSubview:actionBtn];
id rootViewController=[UIApplication sharedApplication].delegate.window.rootViewController;
if([rootViewController isKindOfClass:[UINavigationController class]])
{
rootViewController=[((UINavigationController *)rootViewController).viewControllers objectAtIndex:0];
}
[rootViewController presentViewController:_alert animated:YES completion:nil];
It works fine.However, if Im trying to enter text in the UITextField by tapping it, the keyboard doesn't appear and hence Im not be able to type anything within the UITextField. How can I sort this out?
the reason is you added textField, button, all those inside toolview , but the toolview height is very less
change your toolView height from 44
into 500 or else (combination of textfield, button + 50).
Change below statement
UIView *toolView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 270.0f, 44.f)];
to
UIView *toolView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 270.0f, 500.f)];
Update
change this line
[self presentViewController:alert animated:YES completion:nil];
into
id rootViewController=[UIApplication sharedApplication].delegate.window.rootViewController;
if([rootViewController isKindOfClass:[UINavigationController class]])
{
rootViewController=[((UINavigationController *)rootViewController).viewControllers objectAtIndex:0];
}
[rootViewController presentViewController:alert animated:YES completion:nil];
Update New
UIViewController *rootViewController=[UIApplication sharedApplication].delegate.window.rootViewController;
if([rootViewController isKindOfClass:[UINavigationController class]])
{
rootViewController=[((UINavigationController *)rootViewController).viewControllers objectAtIndex:0];
}else
{
while (rootViewController.presentedViewController) {
rootViewController = rootViewController.presentedViewController;
}
}
[rootViewController presentViewController:alert animated:YES completion:nil];
Swift
var rootViewController: UIViewController = UIApplication.sharedApplication().delegate.window.rootViewController
if (rootViewController is UINavigationController.self) {
rootViewController = ((rootViewController as! UINavigationController)).viewControllers[0]
}
else {
while rootViewController.presentedViewController {
rootViewController = rootViewController.presentedViewController
}
}
rootViewController.presentViewController(alert, animated: true, completion: { _ in })
Try this it may help you:-
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:#" Your message " preferredStyle:UIAlertControllerStyleAlert];
UIView *toolView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 270, 200)];
toolView.backgroundColor = [UIColor blackColor];
CGRect buttonFrame = CGRectMake(0, 5, 100, 30);
UIButton *button = [[UIButton alloc] initWithFrame:buttonFrame];
[button setTitle:#"Image" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[toolView addSubview:button];
UITextField *txtField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 270, 44)];
txtField.borderStyle = UITextBorderStyleRoundedRect;
txtField.backgroundColor = [UIColor grayColor];
txtField.font = [UIFont systemFontOfSize:15];
txtField.placeholder = #"enter text";
txtField.autocorrectionType = UITextAutocorrectionTypeNo;
txtField.keyboardType = UIKeyboardTypeDefault;
txtField.returnKeyType = UIReturnKeyDone;
txtField.clearButtonMode = UITextFieldViewModeWhileEditing;
txtField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
txtField.delegate = (id<UITextFieldDelegate>)self;
[toolView addSubview:txtField];
[txtField setUserInteractionEnabled:YES];
[toolView setUserInteractionEnabled:YES];
[alertController.view setUserInteractionEnabled:YES];
[alertController.view addSubview:toolView];
[self presentViewController:alertController animated:YES completion:nil];

UITextField not selectable

I'm attempting to create a sign in screen for an app I'm working on. Right now I have two UITextFields with an image view behind them. When I try to click on a text field to enter text, nothing happens. I've spent a lot of time trying to figure out this problem but can't find anyone who has had a similar problem. In my LoginViewController's viewDidLoad method I have the following code:
`
[super viewDidLoad];
UIImageView *splashView = [[UIImageView alloc] initWithFrame:self.view.frame];
splashView.image = [UIImage imageNamed:#"Default-568h#2x.png"];
UITextField *username = [[UITextField alloc] initWithFrame:CGRectMake(90, 320, 140, 30)];
username.placeholder = #"username";
username.borderStyle = UITextBorderStyleRoundedRect;
username.returnKeyType = UIReturnKeyDone;
username.textAlignment = NSTextAlignmentLeft;
username.userInteractionEnabled = YES;
[splashView addSubview:username];
UITextField *password = [[UITextField alloc] initWithFrame:CGRectMake(90, 365, 140, 30)];
password.placeholder = #"password";
password.borderStyle = UITextBorderStyleRoundedRect;
password.textAlignment = NSTextAlignmentLeft;
[splashView addSubview:password];
[self.view addSubview:splashView];
`
any help or advice would be appreciated thanks.
Change the place to add Image:
[super viewDidLoad];
UIImageView *splashView = [[UIImageView alloc] initWithFrame:self.view.frame];
splashView.image = [UIImage imageNamed:#"Default-568h#2x.png"];
// The image behind
[self.view addSubview:splashView];
UITextField *username = [[UITextField alloc] initWithFrame:CGRectMake(90, 320, 140, 30)];
username.placeholder = #"username";
username.borderStyle = UITextBorderStyleRoundedRect;
username.returnKeyType = UIReturnKeyDone;
username.textAlignment = NSTextAlignmentLeft;
username.userInteractionEnabled = YES;
// Change this
[self.view addSubview:username];
UITextField *password = [[UITextField alloc] initWithFrame:CGRectMake(90, 365, 140, 30)];
password.placeholder = #"password";
password.borderStyle = UITextBorderStyleRoundedRect;
password.textAlignment = NSTextAlignmentLeft;
//And change this
[self.view addSubview:password];
If you are another image for the other textField add to view first than this.

Add UIActivityIndicatorView to UIActionSheet

I am trying to add an UIActivityIndicatorView to UIActionsSheet in this way:
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:nil
delegate:sharedInstance
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
for(NSMutableDictionary *dict in moreStructure)
{
NSString *value = [dict valueForKey:TITLE_PARAMETER];
[actionSheet addButtonWithTitle:value];
}
[actionSheet addButtonWithTitle:#"Cancel"];
actionSheet.cancelButtonIndex = [moreStructure count];
[actionSheet showInView:((SectionViewController *)sharedInstance.currentViewController).view];
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityView.frame = CGRectMake(100, 500, 15, 15);
[activityView startAnimating];
[actionSheet addSubview:activityView];
When the UIActionSheet appears, however, I do not see an UIActivityIndicatorView on it. Please, help me.
I have try this and this is working... Please check frame of activityView... because its y is 500...
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:nil
delegate:nil
cancelButtonTitle:#"Test"
destructiveButtonTitle:#"Test"
otherButtonTitles:nil];
[actionSheet showInView:self.view];
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityView.frame = CGRectMake(100, 5, 15, 15);
[activityView startAnimating];
[actionSheet addSubview:activityView];
activityView.backgroundColor = [UIColor redColor];
actionSheet.backgroundColor = [UIColor greenColor];
activityView.frame = CGRectMake(100, 500, 15, 15);
// this so this above must change
activityView.frame = CGRectMake(10, 50, 300, 400);

UIButton inside UITextField

I'm trying to put a UIButton inside UITextfield, to act as a "Done" button to resign the responder. I've tried with the following code, when the field starts editing the done button in the UITextField leftView is visible, however if I select a value from the datePicker or make any text input with the keyboard (in simulator), the done button disappears and the right clearButton is shown.
It seems like it toggles between them both, I changed textFld.LeftViewMode to display always the button but that is not what I'd like...
Thanks in advance!.
- (void)viewDidLoad
{
[super viewDidLoad];
txtFld = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 310, 25)];
txtFld.placeholder = #"__/__/____";
txtFld.font = [UIFont fontWithName:#"HelveticaNeue" size:11];
txtFld.textAlignment = NSTextAlignmentCenter;
txtFld.contentVerticalAlignment = UIControlContentHorizontalAlignmentCenter;
txtFld.contentHorizontalAlignment = UIControlContentVerticalAlignmentCenter;
txtFld.clearButtonMode = UITextFieldViewModeWhileEditing;
txtFld.borderStyle = UITextBorderStyleRoundedRect;
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
doneButton.bounds = CGRectMake(0, 0, 40, 20);
doneButton.frame = CGRectMake(0.0, 0.0, 40.0, 20.0);
doneButton.titleLabel.font = [UIFont fontWithName:#"HelveticaNeue" size:10];
[doneButton setTitle:#"Done" forState:UIControlStateNormal];
doneButton.imageEdgeInsets = UIEdgeInsetsMake(0, -16, 0, 0);
[doneButton addTarget:self action:#selector(resignResponder:) forControlEvents:UIControlEventTouchUpInside];
doneButton.userInteractionEnabled = YES;
// Add button to the UITextField
txtFld.leftView = doneButton;
txtFld.leftViewMode = UITextFieldViewModeWhileEditing;
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDate;
[datePicker addTarget:self action:#selector(datePickerValueChanged:) forControlEvents:UIControlEventValueChanged];
[txtFld setInputView:datePicker];
[self.view addSubview:txtFld];
}
-(void)resignResponder:(UIButton *)sender{
UITextField *associatedTxtFld = (UITextField *) sender.superview ;
if ([associatedTxtFld isFirstResponder]) {
[associatedTxtFld resignFirstResponder];
}
}
-(void)datePickerValueChanged:(id)sender{
UIDatePicker *picker = (UIDatePicker *)sender;
NSDateFormatter *formater = [[NSDateFormatter alloc]init];
[formater setDateFormat:#"dd-MM-yyyy"];
txtFld.text = [formater stringFromDate:picker.date];
}
The below code works fine for me . This could be a solution to resign your pickerview
UITextField *dispayNameField = [UITextField alloc]init];
UIButton *userStatusButton = [UIButton buttonWithType:UIButtonTypeCustom];
userStatusButton.frame=CGRectMake(0, 0, 20, 20);
[userStatusButton addTarget:self action:#selector(selectUserStatus) forControlEvents:UIControlEventTouchUpInside];
displayNameField.rightViewMode = UITextFieldViewModeAlways;
displayNameField.rightView = _userStatusButton;
-(void)selectUserStatus
{
displayNameField.inputView = _dataPickerView;
self.editUserProfileScrollView.scrollEnabled = YES;
UIActionSheet *actionSheetForDate = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheetForDate showInView:self.parentViewController.tabBarController.view];
[actionSheetForDate setBounds:CGRectMake(0,0,320, 500)];
UIDatePicker = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 50, 320, 216)];
_dataPickerView.tag = 1;
_dataPickerView.showsSelectionIndicator = YES;
_dataPickerView.dataSource = self;
_dataPickerView.delegate = self;
[_actionSheetForDate addSubview:_dataPickerView];
[_actionSheetForDate sendSubviewToBack:_dataPickerView];
UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerToolbar.barStyle = UIBarStyleBlackTranslucent;
[pickerToolbar sizeToFit];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(dismissActionSheetUserField)];
UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *btnBarCancel = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:#selector(dismissActionSheetUserField)];
[pickerToolbar setItems:[NSArray arrayWithObjects:btnBarCancel,flexSpace,doneButton, nil] animated:YES];
[_actionSheetForDate addSubview:pickerToolbar];
displayNameField.inputAccessoryView = pickerToolbar;
}

UIPicker / UIActionSheet works fine on iPhone but only thin line on iPad

The following Code works fine on iPhone, but not on iPad. Only get a thin line instead of the full view. Have been researching and maybe something with the rect for the picker? All size numbers seem to be reasonable.
actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil
cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
if ( isipad ) pickerFrame = CGRectMake(0, 345, 400, 216);
pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[actionSheet addSubview:pickerView];
[pickerView release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Select"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(10, 7.0f, 100.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:#selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[closeButton release];
UISegmentedControl *skipButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"Skip Birth Year"]];
skipButton.momentary = YES;
skipButton.frame = CGRectMake(200, 7.0f, 100.0f, 30.0f);
skipButton.segmentedControlStyle = UISegmentedControlStyleBar;
skipButton.tintColor = [UIColor blackColor];
[skipButton addTarget:self action:#selector(skipActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:skipButton];
[skipButton release];
[actionSheet setBounds:CGRectMake(0, 0, self.view.frame.size.width, 216)];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, self.view.frame.size.width, 216)];
Well, got it to work by putting most of the code in
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
including
pickerFrame = CGRectMake(0, 0, 320, 214);
AND
initWithTitle:#"\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
for the action sheet. Magic I guess.
Is this correct:
CGRect pickerFrame = CGRectMake(0, 40, 0, 0); //This line sets the frame height and width equal to 0.
if ( isipad ) pickerFrame = CGRectMake(0, 345, 400, 216);
Is your isipad bool working ok?
Thanks for your post ort11.
I needed to make an iPad app and I did working copy-paste code from iPhone app and on iPad is the same: a small line :)
My needs is a language chooser only, nothing else.
Here are the codes based on your answer:
- (IBAction)btLanguageChooserPressed {
NSLog(#"btLanguageChooserPressed");
[self createLanguageSheet];
// show the sheet: will be invoked the willPresentActionSheet method
[sheet showInView:self.view];
}
- (void)createLanguageSheet {
NSLog(#"createLanguageSheet()");
// hoolly crap, need to initialize the title with: #"\n\n\n\n\n\n\n\n\n\n\n\n\n\n" to get working!!!
sheet = [[UIActionSheet alloc] initWithTitle:#"\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[sheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
}
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet
{
CGRect pickerFrame = CGRectMake(0, 0, 320, 216);
pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[sheet addSubview:pickerView];
// add close button:
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:#"OK"]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(120, 12, 100, 30);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:#selector(dismissSheet:) forControlEvents:UIControlEventValueChanged];
[sheet addSubview:closeButton];
[sheet setBounds:CGRectMake(0, 0, self.view.frame.size.width, 216)];
//[sheet showInView:self.view];//already called, why need again?
//[sheet setBounds:CGRectMake(0, 0, self.view.frame.size.width, 216)];
}
at runtime I do a cache in a variable:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSLog(#"Selected: %#", [arrayLanguages objectAtIndex:row]) ;
selectedRow = row;
}
and here is the finish:
- (void)dismissSheet:(id)sender {
[sheet dismissWithClickedButtonIndex:0 animated:YES];
NSString* selectedLanguage = [arrayLanguages objectAtIndex:selectedRow];
NSLog(#"dismissSheet() selectedLanguage: %#",selectedLanguage);
switch (selectedRow) {
case 0://English
imgCurrentLanguage.image = [UIImage imageNamed:#"english.png"];
break;
case 1:// Deutsch
break;
case 2://Français
break;
case 3://Italiano
break;
case 4://Español
break;
default:
break;
}
// TODO: do the changes in GUI
}
I am not able to move this actionsheet from the center of the screen to botton- left corner. But I am trying...
I think this would be the cleanest solution :
#interface MyActionSheet : UIActionSheet
#property (nonatomic, strong) IBOutlet UIView * customView;
#end
#implementation MyActionSheet
-(CGRect)bounds {
return self.customView.bounds;
}
#end
then:
MyActionSheet * s = [[MyActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
s.customView = _auxView;
[s addSubview:_auxView];

Resources