I want to submit an iPhone application, and I am concerned about the following line of code which add an Image to the UIActionSheet Button:
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#""
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet addButtonWithTitle:#"Button"];
[[[action valueForKey:#"_buttons"] objectAtIndex:0] setImage:[UIImage imageNamed:#"yourImage.png"] forState:UIControlStateNormal];
does that compromise any of apple app sumbition rules? is it legal? please tell me if so.
Thanks.
It is not legal, since _buttonsis not a public API.
(I would say however that it would pass Apple's review since you are using KVC and they have no way to know that this is a private call. Still, play safe and don't use it!)
Related
I was wondering how to create and customize a UIAlert View Popup, like ones in popular games such as Angry Birds or Cut the Rope.
I just want to say can you please rate my game and have 3 options to choose from. I want to design it so the text font and color changes and the background color can change to a picture or something? Thanks in Advance! :)
If your UIAlert is short enough to fit without the inherent scroll bar of longer text, then this will work:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Title Here" message:#Message here..." delegate:self cancelButtonTitle:#"Okay" otherButtonTitles:nil];
((UILabel*)[[alert subviews] objectAtIndex:1]).textAlignment = UITextAlignmentLeft;
((UILabel*)[[alert subviews] objectAtIndex:1]).font = [UIFont systemFontOfSize:12];
[alert show];
You should try subclassing UIAlertView using this tutorial. Such UIAlertViews can be achieved with either a subclass of UIAlertView or by creating a separate view all together that simulates the look and feel of a UIAlertView.
I need to know what this UI component is called ? It looks like an Alert but has textfeilds and buttons in it ?
1.) What is this UIComponent called ?
2.) Is there any video tutorial which shows how to implement this ? (If so link) or any tutorials that discuss the implementation of this
It's UIAlertView
Here is the tutorial to make custom UIAlertView
That is an Android component, there is no equivalent in iOS.
There is the UIAlertView, but you cannot edit text within it.
http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIAlertView_Class/UIAlertView/UIAlertView.html#//apple_ref/occ/cl/UIAlertView
If you want to be able to let users edit text in the component, you have to create it from scratch, e.g. create a UIView and add a UITextView to it and some UIButtons and create the functionality to display/dismiss the component yourself.
AlertView
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Title"
message:#"Message"
delegate:nil
cancelButtonTitle:#"Cancel"
otherButtonTitles:nil];
[alert show];
[alert release];
The component on iPhone is called a UIAlertView. You can add subviews in it to get text-fields, although this is not recommended by Apple - but you won't get rejected either. In iOS5, there are dedicated UIAlertView types for this. If you are building for iOS5, this is the method you should use.
I would like to add a bunch of UILabels or NSStrings to the UIALertView since I have run out of space on my display.
UIAlertView *alertDialog;
alertDialog = [[UIAlertView alloc]
initWithTitle:#"random" message:nil delegate:self cancelButtonTitle:#"Dismiss" otherButtonTitles: nil];
//firstString=[[UILabel alloc]initWithFrame: CGRectMake(12.0, 70.0, 260.0, 25.0)];
[alertDialog addSubview:firstString];
[alertDialog show];
[alertDialog release];
I can tell you from experience that this is a bad idea. In earlier version or iOS there were tricks using undocumented behavior, Apple made changes to the underlaying code and it all broke badly. Just create a UIView the way you like. If you want to dim the rest of the screen just place a semi-transparenr view over the screen and under your view.
You can use a alternative implementation of an alert view. One, that is not a subclass of UIAlertView — so it is absolutely independent to any changes Apple may release. And you have the possibility to add any subview as a clean property.
TSAlertView is such an alternative implementation.
you can use uitextfield to do so ,
simply change textcolor to while , and change background color to clearColor
I'n talking about the small windows with buttons that come from the bottom when you need to confirm some action. For example, if you want to delete a photo from an album and press the trash icon, a small view jumps from the bottom and asks if you want to delete the photo or cancel
How do I get those views to appear?
Use a UIActionSheet.
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:#"Some Action"
delegate:self
cancelButtonTitle:#"Cancel"
destructiveButtonTitle:#"OK"
otherButtonTitles: nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
[actionSheet release];
You'll want to look at the UIActionSheet object: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIActionSheet_Class/Reference/Reference.html
An example here: http://ykyuen.wordpress.com/2010/04/14/iphone-uiactionsheet-example/
this is the code i have taken form.....
- (void)willPresentAlertView:(UIAlertView *)alertView
{
[[[alertView subviews] objectAtIndex:2] setBackgroundColor:[UIColor colorWithRed:0.5 green:0.0f blue:0.0f alpha:1.0f]];
}
- (void) presentSheet
{
UIAlertView *baseAlert = [[UIAlertView alloc]
initWithTitle:#"Alert" message:#"This alert allows the user to choose between a 'safe' and a 'deadly' choice, indicated by button color.\n\n\n\n"
delegate:self cancelButtonTitle:nil
otherButtonTitles:#"Deadly!", #"Safe", nil];
UITextField *txtFld = [[UITextField alloc] initWithFrame:CGRectMake(60,10,240,31)];
[txtFld setDelegate:self];
[txtFld setBackgroundColor:[UIColor clearColor]];
[baseAlert addSubView:txtFld];
[txtFld release];
[baseAlert show];
}
my question is If it is allowed to change the basic Look and feel of the apple's provided UIControls, because I dont see any reason that apple should not allow this type of customisation.
Alert views have long been standardized to for the same reason things like fire extinguishers and safety signs are standardized i.e. you don't want people to have to puzzle out a new interface while something is going wrong.
In general, it is a bad idea to change something in the interface that has been highly standardized. What benefit will it bring to the end user? Will they think, "Damn, I lost all my data but the alert that told me that sure did look artistic!" More likely, they won't understand that the dialog is actually an alert but rather part of the apps normal functioning.
Having said all that, there is nothing to stop you from creating your own custom view and presenting it modally. That is a far safer and easier route than mucking about under the hood of the Apple API.
I don't know if Apple will reject an app for accessing undocumented subviews, but they certainly recommend against it. In fact, when I was at the iPhone tech talk last week a developer evangelist specifically said not to do this because the implementations will change and your app will break.