在UIKit中谁才最我们的敌人?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在UIKit中谁才最我们的敌人?相关的知识,希望对你有一定的参考价值。
我们在开发ios的过程中,都在调用系统的类,每个类都有丰富的API,但是在开的中很多类型与API我们是用不着的.
当系统的类满不了我们的需要的时候,我就就需要Custom了.在Custom不要贪途方便什么都放一堆.
看看以下这个表,你发现这些对象在内存的大小.相信还有不少人还是不知道的.单位为Bytes
/*
2016-03-04 20:15:55.218 Debug[25079:992455] UIAcceleration---- 40
2016-03-04 20:15:55.219 Debug[25079:992455] UIAccelerometer---- 40
2016-03-04 20:15:55.219 Debug[25079:992455] UIBarItem---- 16
2016-03-04 20:15:55.219 Debug[25079:992455] UIBarButtonItem---- 272
2016-03-04 20:15:55.219 Debug[25079:992455] UITabBarItem---- 168
2016-03-04 20:15:55.220 Debug[25079:992455] UIBezierPath---- 96
2016-03-04 20:15:55.220 Debug[25079:992455] UIColor---- 16
2016-03-04 20:15:55.220 Debug[25079:992455] UIDevice---- 24
2016-03-04 20:15:55.220 Debug[25079:992455] UIEvent---- 32
2016-03-04 20:15:55.221 Debug[25079:992455] UIGestureRecognizer---- 232
2016-03-04 20:15:55.221 Debug[25079:992455] UILongPressGestureRecognizer---- 384
2016-03-04 20:15:55.221 Debug[25079:992455] UIPanGestureRecognizer---- 384
2016-03-04 20:15:55.221 Debug[25079:992455] UIPinchGestureRecognizer---- 384
2016-03-04 20:15:55.221 Debug[25079:992455] UIRotationGestureRecognizer---- 336
2016-03-04 20:15:55.222 Debug[25079:992455] UISwipeGestureRecognizer---- 352
2016-03-04 20:15:55.222 Debug[25079:992455] UITapGestureRecognizer---- 272
2016-03-04 20:15:55.222 Debug[25079:992455] UIImage---- 80
2016-03-04 20:15:55.222 Debug[25079:992455] UILocalizedIndexedCollation---- 80
2016-03-04 20:15:55.262 Debug[25079:992455] UILocalNotification---- 8
2016-03-04 20:15:55.262 Debug[25079:992455] UIMenuController---- 48
2016-03-04 20:15:55.262 Debug[25079:992455] UIMenuItem---- 32
2016-03-04 20:15:55.262 Debug[25079:992455] UINavigationItem---- 240
2016-03-04 20:15:55.262 Debug[25079:992455] UINib---- 16
2016-03-04 20:15:55.263 Debug[25079:992455] UIPasteboard---- 16
2016-03-04 20:15:55.263 Debug[25079:992455] UIPopoverController---- 480
2016-03-04 20:15:55.263 Debug[25079:992455] UIPrintFormatter---- 120
2016-03-04 20:15:55.263 Debug[25079:992455] UISimpleTextPrintFormatter---- 120
2016-03-04 20:15:55.263 Debug[25079:992455] UIMarkupTextPrintFormatter---- 144
2016-03-04 20:15:55.264 Debug[25079:992455] UIViewPrintFormatter---- 128
2016-03-04 20:15:55.264 Debug[25079:992455] UIPrintInfo---- 80
2016-03-04 20:15:55.264 Debug[25079:992455] UIPrintInteractionController---- 128
2016-03-04 20:15:55.264 Debug[25079:992455] UIPrintPageRenderer---- 112
2016-03-04 20:15:55.265 Debug[25079:992455] UIPrintPaper---- 24
2016-03-04 20:15:55.265 Debug[25079:992455] UIResponder---- 16
2016-03-04 20:15:55.265 Debug[25079:992455] UIApplication---- 656
2016-03-04 20:15:55.265 Debug[25079:992455] UIView---- 368
2016-03-04 20:15:55.265 Debug[25079:992455] UIViewController---- 784
2016-03-04 20:15:55.266 Debug[25079:992455] UITabBarController---- 992
2016-03-04 20:15:55.266 Debug[25079:992455] UITableViewController---- 832
2016-03-04 20:15:55.266 Debug[25079:992455] UINavigationController---- 1080
2016-03-04 20:15:55.266 Debug[25079:992455] UIImagePickerController---- 1160
2016-03-04 20:15:55.267 Debug[25079:992455] UIVideoEditorController---- 1104
2016-03-04 20:15:55.267 Debug[25079:992455] UIWindow---- 776
2016-03-04 20:15:55.267 Debug[25079:992455] UILabel---- 520
2016-03-04 20:15:55.267 Debug[25079:992455] UIPickerView---- 520
2016-03-04 20:15:55.268 Debug[25079:992455] UIActivityIndicatorView---- 520
2016-03-04 20:15:55.268 Debug[25079:992455] UIImageView---- 432
2016-03-04 20:15:55.268 Debug[25079:992455] UITabBar---- 592
2016-03-04 20:15:55.269 Debug[25079:992455] UIToolbar---- 464
2016-03-04 20:15:55.269 Debug[25079:992455] UINavigationBar---- 568
2016-03-04 20:15:55.269 Debug[25079:992455] UITableViewCell---- 976
2016-03-04 20:15:55.270 Debug[25079:992455] UIActionSheet---- 456
2016-03-04 20:15:55.270 Debug[25079:992455] UIAlertView---- 488
2016-03-04 20:15:55.270 Debug[25079:992455] UIScrollView---- 1104
2016-03-04 20:15:55.270 Debug[25079:992455] UISearchBar---- 656
2016-03-04 20:15:55.289 Debug[25079:992455] UIWebView---- 376
2016-03-04 20:15:55.289 Debug[25079:992455] UIControl---- 408
2016-03-04 20:15:55.290 Debug[25079:992455] UITableView---- 2112
2016-03-04 20:15:55.290 Debug[25079:992455] UITextView---- 1344
2016-03-04 20:15:55.290 Debug[25079:992455] UIButton---- 664
2016-03-04 20:15:55.290 Debug[25079:992455] UIDatePicker---- 424
2016-03-04 20:15:55.290 Debug[25079:992455] UIPageControl---- 520
2016-03-04 20:15:55.291 Debug[25079:992455] UISegmentedControl---- 488
2016-03-04 20:15:55.291 Debug[25079:992455] UITextField---- 824
2016-03-04 20:15:55.291 Debug[25079:992455] UISlider---- 560
2016-03-04 20:15:55.292 Debug[25079:992455] UISwitch---- 448
2016-03-04 20:15:55.322 Debug[25079:992455] UIScreen---- 352
2016-03-04 20:15:55.323 Debug[25079:992455] UIScreenMode---- 24
2016-03-04 20:15:55.323 Debug[25079:992455] UISearchDisplayController---- 312
2016-03-04 20:15:55.323 Debug[25079:992455] UITextChecker---- 24
2016-03-04 20:15:55.323 Debug[25079:992455] UITextInputStringTokenizer---- 16
2016-03-04 20:15:55.323 Debug[25079:992455] UITextPosition---- 8
2016-03-04 20:15:55.324 Debug[25079:992455] UITextRange---- 8
2016-03-04 20:15:55.324 Debug[25079:992455] UITouch---- 296
*/
NSLog(@"UIAcceleration---- %lu",class_getInstanceSize([UIAcceleration class]));
NSLog(@"UIAccelerometer---- %lu",class_getInstanceSize([UIAccelerometer class]));
NSLog(@"UIBarItem---- %lu",class_getInstanceSize([UIBarItem class]));
NSLog(@"UIBarButtonItem---- %lu",class_getInstanceSize([UIBarButtonItem class]));
NSLog(@"UITabBarItem---- %lu",class_getInstanceSize([UITabBarItem class]));
NSLog(@"UIBezierPath---- %lu",class_getInstanceSize([UIBezierPath class]));
NSLog(@"UIColor---- %lu",class_getInstanceSize([UIColor class]));
NSLog(@"UIDevice---- %lu",class_getInstanceSize([UIDevice class]));
NSLog(@"UIEvent---- %lu",class_getInstanceSize([UIEvent class]));
NSLog(@"UIGestureRecognizer---- %lu",class_getInstanceSize([UIGestureRecognizer class]));
NSLog(@"UILongPressGestureRecognizer---- %lu",class_getInstanceSize([UILongPressGestureRecognizer class]));
NSLog(@"UIPanGestureRecognizer---- %lu",class_getInstanceSize([UIPanGestureRecognizer class]));
NSLog(@"UIPinchGestureRecognizer---- %lu",class_getInstanceSize([UIPinchGestureRecognizer class]));
NSLog(@"UIRotationGestureRecognizer---- %lu",class_getInstanceSize([UIRotationGestureRecognizer class]));
NSLog(@"UISwipeGestureRecognizer---- %lu",class_getInstanceSize([UISwipeGestureRecognizer class]));
NSLog(@"UITapGestureRecognizer---- %lu",class_getInstanceSize([UITapGestureRecognizer class]));
NSLog(@"UIImage---- %lu",class_getInstanceSize([UIImage class]));
NSLog(@"UILocalizedIndexedCollation---- %lu",class_getInstanceSize([UILocalizedIndexedCollation class]));
NSLog(@"UILocalNotification---- %lu",class_getInstanceSize([UILocalNotification class]));
NSLog(@"UIMenuController---- %lu",class_getInstanceSize([UIMenuController class]));
NSLog(@"UIMenuItem---- %lu",class_getInstanceSize([UIMenuItem class]));
NSLog(@"UINavigationItem---- %lu",class_getInstanceSize([UINavigationItem class]));
NSLog(@"UINib---- %lu",class_getInstanceSize([UINib class]));
NSLog(@"UIPasteboard---- %lu",class_getInstanceSize([UIPasteboard class]));
NSLog(@"UIPopoverController---- %lu",class_getInstanceSize([UIPopoverController class]));
NSLog(@"UIPrintFormatter---- %lu",class_getInstanceSize([UIPrintFormatter class]));
NSLog(@"UISimpleTextPrintFormatter---- %lu",class_getInstanceSize([UISimpleTextPrintFormatter class]));
NSLog(@"UIMarkupTextPrintFormatter---- %lu",class_getInstanceSize([UIMarkupTextPrintFormatter class]));
NSLog(@"UIViewPrintFormatter---- %lu",class_getInstanceSize([UIViewPrintFormatter class]));
NSLog(@"UIPrintInfo---- %lu",class_getInstanceSize([UIPrintInfo class]));
NSLog(@"UIPrintInteractionController---- %lu",class_getInstanceSize([UIPrintInteractionController class]));
NSLog(@"UIPrintPageRenderer---- %lu",class_getInstanceSize([UIPrintPageRenderer class]));
NSLog(@"UIPrintPaper---- %lu",class_getInstanceSize([UIPrintPaper class]));
NSLog(@"UIResponder---- %lu",class_getInstanceSize([UIResponder class]));
NSLog(@"UIApplication---- %lu",class_getInstanceSize([UIApplication class]));
NSLog(@"UIView---- %lu",class_getInstanceSize([UIView class]));
NSLog(@"UIViewController---- %lu",class_getInstanceSize([UIViewController class]));
NSLog(@"UITabBarController---- %lu",class_getInstanceSize([UITabBarController class]));
NSLog(@"UITableViewController---- %lu",class_getInstanceSize([UITableViewController class]));
NSLog(@"UINavigationController---- %lu",class_getInstanceSize([UINavigationController class]));
NSLog(@"UIImagePickerController---- %lu",class_getInstanceSize([UIImagePickerController class]));
NSLog(@"UIVideoEditorController---- %lu",class_getInstanceSize([UIVideoEditorController class]));
NSLog(@"UIWindow---- %lu",class_getInstanceSize([UIWindow class]));
NSLog(@"UILabel---- %lu",class_getInstanceSize([UILabel class]));
NSLog(@"UIPickerView---- %lu",class_getInstanceSize([UIPickerView class]));
NSLog(@"UIActivityIndicatorView---- %lu",class_getInstanceSize([UIActivityIndicatorView class]));
NSLog(@"UIImageView---- %lu",class_getInstanceSize([UIImageView class]));
NSLog(@"UITabBar---- %lu",class_getInstanceSize([UITabBar class]));
NSLog(@"UIToolbar---- %lu",class_getInstanceSize([UIToolbar class]));
NSLog(@"UINavigationBar---- %lu",class_getInstanceSize([UINavigationBar class]));
NSLog(@"UITableViewCell---- %lu",class_getInstanceSize([UITableViewCell class]));
NSLog(@"UIActionSheet---- %lu",class_getInstanceSize([UIActionSheet class]));
NSLog(@"UIAlertView---- %lu",class_getInstanceSize([UIAlertView class]));
NSLog(@"UIScrollView---- %lu",class_getInstanceSize([UIScrollView class]));
NSLog(@"UISearchBar---- %lu",class_getInstanceSize([UISearchBar class]));
NSLog(@"UIWebView---- %lu",class_getInstanceSize([UIWebView class]));
NSLog(@"UIControl---- %lu",class_getInstanceSize([UIControl class]));
NSLog(@"UITableView---- %lu",class_getInstanceSize([UITableView class]));
NSLog(@"UITextView---- %lu",class_getInstanceSize([UITextView class]));
NSLog(@"UIButton---- %lu",class_getInstanceSize([UIButton class]));
NSLog(@"UIDatePicker---- %lu",class_getInstanceSize([UIDatePicker class]));
NSLog(@"UIPageControl---- %lu",class_getInstanceSize([UIPageControl class]));
NSLog(@"UISegmentedControl---- %lu",class_getInstanceSize([UISegmentedControl class]));
NSLog(@"UITextField---- %lu",class_getInstanceSize([UITextField class]));
NSLog(@"UISlider---- %lu",class_getInstanceSize([UISlider class]));
NSLog(@"UISwitch---- %lu",class_getInstanceSize([UISwitch class]));
NSLog(@"UIScreen---- %lu",class_getInstanceSize([UIScreen class]));
NSLog(@"UIScreenMode---- %lu",class_getInstanceSize([UIScreenMode class]));
NSLog(@"UISearchDisplayController---- %lu",class_getInstanceSize([UISearchDisplayController class]));
NSLog(@"UITextChecker---- %lu",class_getInstanceSize([UITextChecker class]));
NSLog(@"UITextInputStringTokenizer---- %lu",class_getInstanceSize([UITextInputStringTokenizer class]));
NSLog(@"UITextPosition---- %lu",class_getInstanceSize([UITextPosition class]));
NSLog(@"UITextRange---- %lu",class_getInstanceSize([UITextRange class]));
NSLog(@"UITouch---- %lu",class_getInstanceSize([UITouch class]));
由此可得出,往往我们的APP开发到一个某时期的时候就会发现页面开卡顿,UITableView\UITableViewCell最占内存,开始自定义吧!
以上是关于在UIKit中谁才最我们的敌人?的主要内容,如果未能解决你的问题,请参考以下文章