Tips and Tricks for ios development

In this post, i am going to tell you some of the tips and tricks for different scenarios of IOS development.

1. Scale an UIImageView or view
               To scale an UIImageView/UIView in IOS we have CGAffineTransformScale with which we can scale our UIImageView/UIView.In this method we will pass current transform of our View and x, y values according to which we want to scale our view. Below is the code chunk that shows how we can use it

 CGAffineTransform transform = CGAffineTransformScale([tomatoOrEggObjectImageView transform], 0.5, 0.5);
 tomatoOrEggObjectImageView.transform = transform;

2. Remove white line shown in UITabBarcontroller in IOS 7
                                    In IOS 7 most of us faced a common issues, a white line is displayed in TabBar of UITabBarController. To fix this we will set empty image to shadowImage of tabBar. To remove this we can use below code

[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];

3. Adjust edges of your controls in IOS 7
                              With introduction of IOS 7, Apple Inc. changes mechanism of displaying objects/controls in a view, they will use full screen layout by default. To over come this we will set its property edgesForExtendedLayout to UIRectEdgeNone. Below is the code that shows how we can achieve it

    if ([self  respondsToSelector:@selector(edgesForExtendedLayout:)])

4. Add a audio file or other file to project but it never appears when running it on simulator/device
                            Sometimes we add files to our project and when try to run it app either crashed out or no file retrieved at specific location. Recently, i came across this situation and after 15 minutes i found that i did not link it to target while adding it.And this is the fix, do check for your file that it is added to target if you are facing such kind of problem.

5. Get image name for the image assigned to UIImageView
                                      We can get image name assigned to our UIImageView by using setAccessibilityIdentifier property. Below is the code that shows how we can use it

  [tomatoOrEggObjectImageView.image setAccessibilityIdentifier:@”NewImage.png”];

To get name we will us below line

  NSLog(@”Iamge Name == %@”,[tomatoOrEggObjectImageView.image accessibilityIdentifier]);

6. Show separator line from start point of UITableView in IOS 7
                                                We will use setSeparatorInset method to  start separartor line from start point of UITableView. Below is the code that shows how we can use it

if ([bookmarkTableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [bookmarkTableView setSeparatorInset:UIEdgeInsetsZero];