Tips for developing iOS

Source: Internet
Author: User

 http://www.jianshu.com/p/50b63a221f09Some tips on iOS tableview do not display the cell with no content?

Like this, I don't want to let the empty ones below show.

Very simple.

self.tableView.tableFooterView = [[UIView alloc] init];

Tried all the same.

After this sentence, it became.

What do I do if I customize the Leftbarbuttonitem left slide return gesture to fail?
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]                                         initWithImage:img                                         style:UIBarButtonItemStylePlain target:self action:@selector(onBack:)];self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
ScrollView inexplicable can not viewcontroller to the top how to do?
self.automaticallyAdjustsScrollViewInsets = NO;
Keyboard event Write good irritability, all want to fall keyboard, how to do?
    1. Buy a sturdy keyboard.
    2. Use iqkeyboardmanager (can be searched on GitHub), the waist does not ache after use, the leg also is not sour.
Why is my app always out of the flow and what's wrong with it?

This artifact is called: Kmcgeigercounter go to GitHub to carry it.

How to adjust the position of separaline without creating a new cell?

_mytableview.separatorinset = Uiedgeinsetsmake (0, 100, 0, 0);

How to click Self.view to let the keyboard, need to add a tapgestures?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{   [self.view endEditing:YES];}
How to set the default background image for each viewcontroller?

Use the base class Ah, juvenile.

Want to change in the code in the Xib add layoutattributes, but how to use code to find AH?

Pull your restraints like a button. Nslayoutattribute can also pull the line.

How to hide navigationbar when sliding like safari?

Navigationcontroller.hidesbarsonswipe = Yes

Navigation bar return key The title of the belt is too annoying, how to let it disappear!
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60)                                                     forBarMetrics:UIBarMetricsDefault];
CoreData used to be very annoying, grammar and smelly and long, how to do?

Magicalrecord

CollectionView How to realize tableview kind of hover header?

Csstickyheaderflowlayout

Can you use just one pan gesture instead of the uiswipegesture in all directions?
-(void) pan: (Uipangesturerecognizer *) sender{typedef ns_enum (Nsuinteger, uipangesturerecognizerdirection) {Uipangesturerecognizerdirectionundefined,Uipangesturerecognizerdirectionup,Uipangesturerecognizerdirectiondown,Uipangesturerecognizerdirectionleft,Uipangesturerecognizerdirectionright};static Uipangesturerecognizerdirection direction = uipangesturerecognizerdirectionundefined;Switch (sender.state) { Case Uigesturerecognizerstatebegan: {  if (direction = = uipangesturerecognizerdirectionundefined) {  Cgpoint velocity = [Sender VelocityInView:recognizer.view];  BOOL isverticalgesture = fabs (velocity.y) > Fabs (velocity.x);   if (isverticalgesture) {    if (Velocity.y >0) {    Direction = Uipangesturerecognizerdirectiondown;   }else {    Direction = Uipangesturerecognizerdirectionup;   }  }   else {    if (velocity.x >0) {    Direction = Uipangesturerecognizerdirectionright;   }else {    Direction = Uipangesturerecognizerdirectionleft;   }  } }  Break} Case uigesturerecognizerstatechanged: {  switch (direction) {   Case Uipangesturerecognizerdirectionup: {   [Self Handleupwardsgesture:sender];    Break  }   Case Uipangesturerecognizerdirectiondown: {   [Self Handledownwardsgesture:sender];    Break  }   Case Uipangesturerecognizerdirectionleft: {   [Self Handleleftgesture:sender];    Break  }   Case Uipangesturerecognizerdirectionright: {   [Self Handlerightgesture:sender];    Break  }   default: {   Span class= "indent" > break;  } }  break;}  case uigesturerecognizerstateended: {  direction = uipangesturerecognizerdirectionundefined;   break;}  default:   Break;}}                 
How can I stretch a picture so that it doesn't deform?
    1. UIImage *image = [[UIImage imagenamed:@ "xxx"] stretchableimagewithleftcapwidth:10 topcapheight:10];( Just now someone reminded that this has deprecated ha, the method is called resizableimagewithcapinsets).

How to play GIF when this card, there is no better library?

Flipboard is a good fit for you. Https://github.com/Flipboard/FLAnimatedImage

How to add a pull-up refresh in a sentence?

Https://github.com/samvermette/SVPullToRefresh

insert cells at top of table view// call [tableView.pullToRefreshView stopAnimating] when done} position:SVPullToRefreshPositionBottom];
How to change the color of the small tick of the cell in TableView to another color?

_mtableview.tintcolor = [Uicolor Redcolor];

Originally my statusbar is lightcontent, result with Uiimagepickercontroller will cause my statusbar style to turn black, how to do?

-(void) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller Willshowviewcontroller: ( Uiviewcontroller *) Viewcontroller animated: (BOOL) animated {[[UIApplication sharedapplication] SetStatusBarStyle: Uistatusbarstylelightcontent]; }

How do I make my navigationbar transparent instead of blurry?

[Self.navigationbar setbackgroundimage:[uiimage new] forbarmetrics:uibarmetricsdefault]; Self.navigationBar.shadowImage = [UIImage new]; Self.navigationBar.translucent = YES;

How to change the color and position of Uitextfield placeholder?

Inherit Uitextfield, override this method

- (void) drawPlaceholderInRect:(CGRect)rect { [[UIColor blueColor] setFill]; [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment]; }Why do you know so many strange tricks?

Go to StackOverflow brush problem ah, teenager!

What is the difference between cgfloat and float?

Now that the apps on the shelves require support for 64-bit systems, the difference between cgfloat and float is here. command+ Left click CGFloat.

typedef CGFLOAT_TYPE CGFloat;

Here you can see that cgfloat is a macro definition of cgfloat_type, so what is this?

 #if defined (__lp64__) && __lp64__# define cgfloat_type double# define cgfloat_is_double 1# define CGFLOAT_ MIN dbl_min# define cgfloat_max dbl_max #else# define Cgfloat_type float# define cgfloat_is_double 0# define cgfloat_min flt_min# define cgfloat_max flt_max#endif   

The meaning of this passage is that, under 64-bit systems, cgfloat is a double type and a float type under a 32-bit system. CGFloat can ensure that your code is not error-prone under 64-bit systems, so your code should use CGFloat as much as possible. Although he may have caused some unnecessary consumption. But it's safe.

Should constants be defined using Foundation_export or # define?

General iOS There are two ways to define constants, see the following example of my. h file

const kMyConstantString;  FOUNDATION_EXPORT NSString * const kMyConstantString2;

The. m file is defined like this

const kMyConstantString = @"Hello";NSString * const kMyConstantString2 = @"World";

There is also a commonly used # define method.

#define Kmyconstantstring @ "Hello"

What difference does it have?

Use the first method to detect whether the value of a string is equal or faster. For the first one you can use directly (stringInstance == MyFirstConstant) to compare, and define uses this.([stringInstance isEqualToString:MyFirstConstant])

Which efficiency is high, it is obvious. The first is to directly compare the pointer address, and the second is to compare each character of the string in equal form.

What does the static inline function do?

If your. m file requires frequent calls to a function, it can be declared with static inline, which is equivalent to defining the function body as a large macro. But this is not completely effective, can not be completely valid, the function of the body to a large macro definition to see the compiler mood, if it feels that your method is too complex, He won't turn around. He calls the function directly. Like this simple function he must be happy.

static inline CGRect ScaleRect(CGRect rect, float n)

What the hell is this? static void *capturingstillimagecontext = &CapturingStillImageContext;

This declarative approach is commonly used in KVO, which is used as a CONTENXT key to add.

[self addObserver:self forKeyPath:@"stillImageOutput.capturingStillImage" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:CapturingStillImageContext];

This declarative approach can result in <mark>a method to create a unique pointer at compile time.</mark> Create a unique pointer at compile time. Because when the context of the KVO is accidentally repeated, something strange happens. This way can be avoided.

How to quickly locate the crash position?

Select Add Exception Breakpoint

This way, if your app is crash, it will automatically navigate to that sentence.

Fastest way to improve smoothness?

Use instrument to find all view,layer that do not need to be transparent but transparent. all made opaque.

Select Profile

Select the color blended Layers

Choose our recently-Weibo client

And then you'll see these things.

Red or crimson is transparent layers and view, they are the culprit to slow down your FPS, if you do not need to be transparent to get rid of.

A magical tool, Accessorizer.

In the end of the mouth, look at the picture will know.

Tips for developing iOS

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.