Precautions for custom IOS system controls

Source: Internet
Author: User

Generally, when customizing a system control, subviews in the control should be traversed.

[Html]
-(Void) willPresentAlertView :( UIAlertView *) alertView {
For (UIView * view in [alertView subviews])
{
// Determine if it is UILabel
If ([[[view class] description] isEqualToString: @ "UILabel"])
{
// Customize UILabel
}
// Determine if it is UIButton
If ([[view class] description] isw.tostring: @ "UIAlertButton"]
| [[View class] description] isEqualToString: @ "UIThreePartButton"])
{
// Customize UIButton
}
}
}

When you use the [[view class] description] isEqualToString: @ "UIAlertButton"] method to determine whether the current View is a button, there is a drawback, because [[view class] description] has different descriptions on different devices, you can use UIAlertButton or UIThreePartButton in the above method. Of course, there are even more.
In fact, you can use [view isKindOfClass: NSClassFromString (@ "UIButton")] to determine whether to differentiate devices. The modified method is as follows:

[Html]
-(Void) willPresentAlertView :( UIAlertView *) alertView {
For (UIView * view in [alertView subviews])
{
// Determine if it is UILabel
If ([view isKindOfClass: NSClassFromString (@ "UILabel")])
{
// Customize UILabel
}
// Determine if it is UIButton
If ([view isKindOfClass: NSClassFromString (@ "UIButton")])
{
// Customize UIButton
}
}
}


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.