I have this code for showing alert view with two needed extra objects:
- (void)leaveCommentButtonPressed
{
UIAlertView *leaveCommentAlert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Leave comment", nil)
message:@""
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Done", nil];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100, 33)];
[textField setBackgroundColor:[UIColor lightGrayColor]];
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 33, 100, 67)];
[textView setBackgroundColor:[UIColor darkGrayColor]];
[view addSubview:textField];
[view addSubview:textView];
CGFloat system_version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (system_version < 7.0) //For Backward compatibility
{
[leaveCommentAlert addSubview:view];
}
else
{
[leaveCommentAlert setValue:view forKey:@"accessoryView"];
}
[leaveCommentAlert show];
}
But my problem is that I can't calculate width of alertView to set width for my text view and text field.
Maybe there are some other answers how to achieve text field and text view. But my idea is to have UIView
with appropriate size.