Combined with their own practice development experience summed up the 22 iOS development tips, with a very happy tone to easily solve the development process encountered a variety of hardship problems, light reading has been laughing.
1. What if the TableView does not display a cell with no content?
Similar to Figure 1, I don't want to let those empty displays below. Very simple, add "Self.tableView.tableFooterView = [[UIView alloc] init];" Try to say yes, after adding this sentence has become the Figure 2 appearance.
2. What do I do if I customize the Leftbarbuttonitem left slide return gesture to fail?
| 123456 |
Self.navigationItem.leftBarButtonItem = [[Uibarbuttonitem alloc] Initwithimage:img style:uibarbuttonitemstyleplain target:self action: @selector (onback:)]; self.navigationcontroller.interactivepopgesturerecognizer.delegate = (id< uigesturerecognizerdelegate>) self; |
3. ScrollView inexplicable can't viewcontroller to the top of the row?
| 1 |
self.automaticallyAdjustsScrollViewInsets = NO; |
4. Keyboard event Write well irritable, all want to fall keyboard what to do?
- Buy a sturdy keyboard;
- Use iqkeyboardmanager (can be searched on GitHub), the waist does not ache after use, the leg also is not sour.
5. Why my app is always not fluent, what is the problem?
This artifact is called: Kmcgeigercounter, go to GitHub to carry it.
6. How to adjust the position of separaline without creating a new cell?
| 1 |
_myTableView.separatorInset = UIEdgeInsetsMake(0, 100, 0, 0); |
7. How to click Self.view to let the keyboard, need to add a tapgestures?
| 1234 |
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [self.view endEditing:YES];} |
8. How to set the default background image for each viewcontroller?
Use the base class Ah, juvenile.
9. Want to change in the code to add the Layoutattributes in the Xib, but how to use the code to find?
Pull the button like pull your restraint, Nslayoutattribute also can pull the line.
10. How to hide navigationbar when sliding like safari?
| 1 |
navigationController.hidesBarsOnSwipe = Yes |
11. Navigation bar Return key The title of the belt is too annoying, how to let it disappear?
| 12 |
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault]; |
CoreData used to be very annoying, grammar and smelly and long how to do?
Magicrecord
How does CollectionView implement TableView's hover header?
Csstickyheaderflowlayout
14. Can I use only one pan gesture in place of the uiswipegesture in all directions?
| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- (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: { break; } } break; } case UIGestureRecognizerStateEnded: { direction = UIPanGestureRecognizerDirectionUndefined; break; } default: break;}} |
15. How can I stretch the picture so that it doesn't deform?
Method One:
| 1 |
UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10]; |
Note: Developers are reminded that this has been deprecated, now the method is called Resizableimagewithcapinsets.
Method Two,
16. How to play GIF when this card, there is no better library?
Flipboard's flanimatedimage is perfect for you.
17. How to add a pull-up refresh in a sentence?
Using the Svpulltorefresh library:
| 1234 |
[tableView addPullToRefreshWithActionHandler:^{// prepend data to dataSource, insert cells at top of table view// call [tableView.pullToRefreshView stopAnimating] when done} position:SVPullToRefreshPositionBottom]; |
18. How do I change the color of the TableView cell to another color?
| 1 |
_mTableView.tintColor = [UIColor redColor]; |
19. Originally my StatusBar is lightcontent, the result uses uiimagepickercontroller will cause my StatusBar's style to turn black, how to do?
| 1234 |
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{ [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];} |
20. How do I make my navigationbar transparent rather than blurry?
| 1234 |
[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];self.navigationBar.shadowImage = [UIImage new];self.navigationBar.translucent = YES; |
21. How to change the color and position of Uitextfield placeholder?
Inherit Uitextfield, overriding this method:
| 1234 |
- (void) drawPlaceholderInRect:(CGRect)rect { [[UIColor blueColor] setFill]; [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];} |
22. Why do you know so many strange tricks?
Go stack Overflow brush problem ah, teenager!
22 Splendor developed by iOS