iOS Trivia points

Source: Internet
Author: User

Get Picture Cache

1. Import

#import "SDImageCache.h"

Convert B units to M

[NSString stringwithformat:@ "%.2FM", (double) [[Sdimagecache Sharedimagecache] getsize]/1000/1000];

Clear the picture cache

[[Sdimagecache Sharedimagecache] cleardisk];

Get all file caches in a folder

Folder Enumerator, you can enumerate all the files within this folder and subfolders of this folder

Nsdirectoryenumerator *enumerator = [[Nsfilemanager Defaultmanager] Enumeratoratpath:<[commontool Filedownloadpath]>>> the path of the folder that needs to be traversed];

unsigned long long totalsize = 0;

while ([Enumerator nextobject])

{

Totalsize+=[[enumerator FileAttributes] fileSize];

}

[NSString stringwithformat:@ "%.2FM", (double) totalsize/1000/1000];

Clean up the file cache

[[Nsfilemanager Defaultmanager] Removeitematpath:<[commontool filedownloadpath]>>> need to delete the folder path via Error:nil ];

Auto-Hide Tabbar when push

vc.hidesbottombarwhenpushed = YES;

Self-adapting height

CGRect rect = [_news.intr-needs to get the string-Boundingrectwithsize:cgsizemake (screen_width-30>-needs to be a wide line, 0) options: nsstringdrawinguseslinefragmentorigin| Nsstringdrawingusesfontleading Attributes:@{nsfontattributename:[uifont boldsystemfontofsize:14]} Context:nil];

return rect.size.height+30;

Get the height of the keyboard input box adaptive

_inputview is a custom View plus textField input box

[[Nsnotificationcenter defaultcenter]addobserver:self selector: @selector (keyboardwillchangeframe:) Name: Uikeyboardwillchangeframenotification Object:nil];

-(void) Keyboardwillchangeframe: (nsnotification *) noti{

NSLog (@ "%@", noti.userinfo);

CGRect rect = [[Noti.userinfo Objectforkey:uikeyboardframeenduserinfokey] cgrectvalue];

[UIView Animatewithduration:[[noti.userinfo Objectforkey:uikeyboardanimationdurationuserinfokey] FloatValue] animations:^{

_inputview.frame = CGRectMake (0, rect.origin.y-40, Screen_width, 40);

_tableview.frame = CGRectMake (0, 0, screen_width, _INPUTVIEW.FRAME.ORIGIN.Y);

}];

}

---slide your keyboard down

-(void) scrollviewwillbegindragging: (Uiscrollview *) scrollview{

[Self.view Endediting:yes];

}

Bubble chat dedicated from a pixel point lachen

Self.bubbleImageView.image = [[UIImage imagenamed:@ "Bubbleself.png"] stretchableimagewithleftcapwidth:25 TOPCAPHEIGHT:20];

Set the photo as a round regular avatar

Self.headerImageView.layer.cornerRadius = 30-The radius of the photo size;

Self.headerImageView.layer.masksToBounds = YES;

Set the corner label for the app icon

[[UIApplication sharedapplication] setapplicationiconbadgenumber:number-need to obtain the number];

iOS Trivia points

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.