Reputation: 544
I am trying to create the complex UIAlert View .But i am not getting right mark to get it work Actaully i need the UIAlertView is like this
And ever user enter the text value in textfield and press the OK BUtton it get show on the label also .
I am trying coding like this But it not getting work what was the problem in it
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Set Tags"
message:@"Do you want to add tag.\nExample:-My Content"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message addTextFieldWithValue:@"" label:@"Enter tag Name"];
[message addButtonWithTitle:@"Cancel"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 8, 30, 30)];
NSString *path = [[NSString alloc] initWithString:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"tag.png"]];
UIImage *bkgImg = [[UIImage alloc] initWithContentsOfFile:path];
[imageView setImage:bkgImg];
[bkgImg release];
[path release];
[message addSubview:imageView];
if(FALSE)
{
[message addButtonWithTitle:@"Button 4"];
}
[message show];
[message release]
;
Help me out from this Thank you.
Upvotes: 3
Views: 1359
Reputation: 5765
UIAlertView
is not the component you should be looking to use in this case. It is not supposed to be customized. You should be displaying a modal view (which consists of all the items you listed) and display it using presentModelViewController:animated:
.
Upvotes: 0
Reputation: 165
Harish, I am having a hard time understanding your english so I may not be hitting the mark with this answer. However, If I am understanding the question correctly then I believe I see only one major issue with your code.
From the documentation that I have read on UIAlertView I do not see the method "addTextFieldWithValue" as part of that class. There is however a reference to UIAlertViewStyle which is a property that can be set that will allow you to tell the class to display itself with a text field. You can find the class reference here
[message addTextFieldWithValue:@"" label:@"Enter tag Name"];
//This will not work.
//Instead use this.
[message setAlertViewStyle:UIAlertViewStylePlainTextInput];
Of course you will need to make sure you have the proper delegate methods added to retrieve the value once buttons are clicked.
I've taken your code and created an example project with only a few minor changes. Using my above suggestion the results I get are reflected in the screen shot I have taken below.
Upvotes: 3