What about this custom uialertview?

谁说胖子不能爱 提交于 2020-01-06 15:38:28

问题


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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/1864552/what-about-this-custom-uialertview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!