Create Ad Hoc beta to test ongoing iOS Application

Create Ad Hoc beta to test ongoing iOS Application

Within few simple steps we can make adhoc beta test file for iOS Application. It requires when we needs to provide beta release to testers for the ongoing iOS Application. Also at some stages we have to send beta releases to clients for checking the progress of the application.

For the beta release we can use adhoc distribution or development profile. Here we will use wild card development provisioning which is generic provisioning & used for the multiple application by changing suffix values & keeping bundle name as it is.

So here is the video demonstrate how to generate ipa file for beta testing on devices.

Share
Resize Image without Losing Actual Scale and Proportion

Resize Image without Losing Actual Scale and Proportion

In iOS application, memory management is an important aspect of making a seamless & smooth UI experience. Now to make it more challenging part comes when images are loaded. Most of the memory leaks & issues appear due to a large size of images loaded from the web interface.

So to overcome this issue it becomes necessary to resize an image before its used. While resizing we will have to make sure image will be resized to the size where actually used in the application.

Let’s say from web interface image loaded with the size of 1000 pixels. But we need to show an image on UIImageView which has size 400x400 pixels. So at the time before using actual image needs to be resized.

It will not only less the memory usage but will also improve the overall performance of the app by loading app faster.

While doing image resizing operations it becomes important to make sure image doesn’t lose its scale. If it’s ignored than image will get starched & will not look as it should be. That will result in bad programming & bad interface as well.

So here is the example for resizing the image without losing the actual scale & proportion.

Resize with new width :

This particular function requires passing actual image & new width which you wants to resize an image with & it will automatically calculate the height according to the image scale & proportion & will return a new resized image. It will not lose the actual scale of image & still, an image will be resized.

Read more: Free online mockup sites to generate eyecatchy screenshots for mobile apps

Objective C :

-(UIImage *)resizeImageWithNewWidth:(UIImage *)image newWidth:(CGFloat)nwidth {

float scale = nwidth / image.size.width;

float newHeight = image.size.height * scale;

UIGraphicsBeginImageContext(CGSizeMake(nwidth, newHeight));

[image drawInRect:CGRectMake(0, 0, nwidth, newHeight)];

UIImage *nImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return nImage;

}

Swift :

func resizeImage(image: UIImage, newWidth: CGFloat) -> UIImage {

let scale = newWidth / image.size.width

let newHeight = image.size.height * scale

UIGraphicsBeginImageContext(CGSize(width: newWidth, height: newHeight))

image.draw(in: CGRect(x: 0, y: 0, width: newWidth, height: newHeight))

let newImage = UIGraphicsGetImageFromCurrentImageContext()

UIGraphicsEndImageContext()

return newImage!

}

Resize with new height :

This particular function requires to pass actual image & new height which you wants to resize image with & it will automatically calculate the width according the image scale & proportion & will return new resized image. It will not loose the actual scale of image & still image will be resized.

Objective C :

-(UIImage *)resizeImageWithNewHeight:(UIImage *)image newheight:(CGFloat)nheight {

float scale = nheight / image.size.height;

float newwidth = image.size.width * scale;

UIGraphicsBeginImageContext(CGSizeMake(newwidth, nheight));

[image drawInRect:CGRectMake(0, 0, newwidth, nheight)];

UIImage *nImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return nImage;

}

Swift :

func resizeImage(image: UIImage, newHeight: CGFloat) -> UIImage {

let scale = newHeight / image.size.height

let newWidth = image.size.width * scale

UIGraphicsBeginImageContext(CGSize(width:newWidth, height:newHeight))

image.draw(in: CGRect(x:0, y:0, width:newWidth, height:newHeight))

let newImage = UIGraphicsGetImageFromCurrentImageContext()

UIGraphicsEndImageContext()

return newImage!

}

Share
Storing and Retrieving Data from NSUserDefaults

Storing and Retrieving Data from NSUserDefaults

In this blog, you will find how to manage user default records by storing & retrieving into NSUserDefaults.

By using NSUserDefaults class we can store default settings, preferences or any such default values in string or dictionary or array format. It can be achieved with just a few lines of code & it loads data faster. Its usually used for storing small data where no such complex operations are required to perform.

The main advantage of using NSUserDefaults for storing a small number of values is it loads data faster than other storage options. More importantly, it doesn’t block the main thread. So it’s not slowing down UI operations & make sure app runs smoothly. That’s why NSUserDefaults class is threaded safe.

Here are simple steps for storing, retrieving & removing data from NSUserDefaults.

 

Saving data to NSUserDefaults :

Objective C :

[[NSUserDefaults standardUserDefaults] setObject:strUsername forKey:@”username”];

[[NSUserDefaults standardUserDefaults] synchronize];

Swift :

UserDefaults.standard.set(strUsername, forKey: “username”)

Read more: Top 10 must have WooCommerce Plugins for WordPress site

Retrieving data to NSUserDefaults :

Objective C :

strUsername = [[NSUserDefaults standardUserDefaults] stringForKey:@”username”]

Swift :

let strUsername : String = UserDefaults.standard.value(forKey: “username”) as! String

Removing NSUserDefaults value :

Objective C :

[[NSUserDefaults standardUserDefaults]  removeobjectForKey:@”username”];

Swift :

UserDefaults.standard.removeObject(forKey: “username”)

Share
Use UIGestureRecognizer for Different Touch Events

Use UIGestureRecognizer for Different Touch Events

UIGestureRecognizer class recognizes a sequence of touches & performs on basis of the recognizer. Here is the list of different gesture events.

It’s more useful for adding action events for controls which don’t contain default actions like UIButton.

UITapGestureRecognizer :

Its used for handle single or multiple taps.

UITapGestureRecognizer *gest = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gestureTapped:)];

gest.delegate = self;

[view addGestureRecognizer:gest];

-(void) gestureTapped:(UITapGestureRecognizer)sender {

}

UIPinchGestureRecognizer :

Its used for handle two taps simultaneously. This gesture used generally for image scaling & zooming feature.

UIPinchGestureRecognizer * gest = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(gestureTapped:)];

gest.delegate = self;

[view addGestureRecognizer:gest];

-(void)gestureTapped:(UIPinchGestureRecognizer*)sender {

sender.view.transform = CGAffineTransformScale(sender.view.transform, sender.scale, sender.scale);

sender.scale = 1;

}

Read more: How to Create and Setup a Prefix Header File for iOS

UIRotationGestureRecognizer :

Its used for handle rotation feature. When a user moves two fingers opposite each other circular way. It will rotate the view in the corresponding direction.

UIRotationGestureRecognizer * gest = [[ UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateImage:)];

gest.delegate = self;

[view addGestureRecognizer:gest];

-(void)rotateImage:(UIRotationGestureRecognizer*)sender {

if ([sender state] == UIGestureRecognizerStateBegan || [sender state] == UIGestureRecognizerStateChanged) {

[sender view].transform = CGAffineTransformRotate([[sender view] transform], [sender rotation]);

[sender setRotation:0];

}

}

UISwipeGestureRecognizer :

Its used for handle actions on swipe. Move views on swiped direction or actions on image with swipe to remove or swipe to load new image.

UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwap:)];

switch (self.direction) {

case DirectionFromTop:

swipe.direction = UISwipeGestureRecognizerDirectionDown;

break;

case DirectionFromLeft:

swipe.direction = UISwipeGestureRecognizerDirectionRight;

break;

case DirectionFromBottom:

swipe.direction = UISwipeGestureRecognizerDirectionUp;

break;

case DirectionFromRight:

swipe.direction = UISwipeGestureRecognizerDirectionLeft;

break;

}

[view addGestureRecognizer:swipe];

-(void)didSwap:(UISwipeGestureRecognizer*)gesture {

}

UIPanGestureRecognizer :

Its used for handle dragging actions like moving images into view or moving any other objects on finger movement.

UIPanGestureRecognizer *gest = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanImage:)];

[imgViewStyleOutfit addGestureRecognizer:gest];

– (void)handlePanImage:(UIPanGestureRecognizer *)sender {

static CGPoint originalCenter;

if (sender.state == UIGestureRecognizerStateBegan) {

originalCenter = sender.view.center;

[sender.view.superview bringSubviewToFront:sender.view];

} else if (sender.state == UIGestureRecognizerStateChanged) {

CGPoint translation = [sender translationInView:self.view];

sender.view.center = CGPointMake(originalCenter.x + translation.x, originalCenter.y + translation.y);

}

}

UILongPressGestureRecognizer :

Its used for handle long press events. For that user needs to press for minimum amount of time to call actions.

UILongPressGestureRecognizer *gest = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(hangleLongPress:)];

[view addGestureRecognizer:gest];

-(void)hangleLongPress:(UILongPressGestureRecognizer*)sender {

if (sender.state == UIGestureRecognizerStateBegan) {

}

}

Share
How to Create Single View iOS Application

How to Create Single View iOS Application

Creating single view application with hello word is easy with just a few steps. Below are described steps for starting up native application development in iOS with simple Hello word application.

  • Open Xcode from application folder or find it from finder & open it
  • Directly click create Project or select from file -> New -> Project
  • Now it will ask for to choose a template for the project. Select SingleView App & click next

Read more: How to Create and Setup a Prefix Header File for iOS

  • Next step is to set app name, bundle name & select Language. Check below screenshot.
  • In product name add your application name as you wish. It will be editable later on.
  • Select Team from a drop-down. By default, the team will be your system admin name
  • Type organization name. If you are an individual developer you can add your name or company name
  • Now the most important part is Language selection. Note that once you selected Language than it will not be editable later on. So it becomes more important to think about the future scope of the application & choose the language.
  • You can tick below check marks for Use core data & unit tests depending on required usage during the development. We will keep it unticked as it’s not required in the application right now
  • Once all fields fill up properly then click next.
  • Now it will ask to choose a path. Select location where you would like to save the project source
  • An application is now ready for the development you can start making simple controls on it & run it on a simulator for testing
  • Below the full video for creating simple single view hello word application
Share
Quick Tips to Speed up Macbook Like a Pro

Quick Tips to Speed up Macbook Like a Pro

Are you using MacBook or any other Mac system with development tools or developing apps? Then you may definitely get an issue with speed. Although usually Mac systems are configured with minimum 4 GB ram still it sometimes stucks while doing multitasking.

Consider a case while you are developing application & you will need to test the application on a simulator that will be a tidy process. You might do close unnecessary apps or sometimes have to even close the apps which you really need to keep open for making the system run smoothly.

We often consider open apps who takes more ram usage but we forget that there are some hidden activities which also consumes lots of memory & due to that system gets hanged or sometimes becomes unresponsive or stuck in the spinner loading.

 

There are few simple tricks you should try out to make your mac system runs smoother with just a couple of steps,

 

  • The first option is you have to check & understand the possible memory usage on your system. Like you are using advanced development tools like Xcode, Studio or Movie maker like tools requires more memory. So at the time its wise to upgrade your ram with at least 8 GB. That will be more than enough for run multitasking or developing tools run smoothly without any interruption.
  • If you think dashboard tools are not frequently used than remove it. To remove it go to System Preferences -> Mission Control -> Select Dashboard dropdown & make it off
  • If you are using the browser then close unnecessary tabs. Some of the sites with continues and flows may consume more memory usage & can slow down your system process
  • You can see which process is taking more memory from the Activity Monitor option. Find Activity Monitor from finder & open it. See below screenshot how it shows which process taking how much memory.

Read more: Important Tips to Test iPhone Application

  • Make sure keep your system updated with new updates provided by the apple. Keep all your software up to date. As new versions always release with the bug improvements so that might help your system to run smoothly
  • Keep removing cache files from browser & keep it clean as cache files consume lots of memory.
  • Remove unused or unnecessary files & folders from disk & keep disk clean
  • Keep the trash clean. Users often doing this mistakes by removing the files but not removing it permanently. So as it’s in the trash it will still consume your disk space so logically the file is still in your system but in a trash folder. So keep cleaning trash folder as well.
  • Don’t save any files directly on a desktop. Keep always all the files in the documents folder
  • Make sure you don’t have any apps in your application folder which are not in use at all. That takes unnecessary space on your disk.
  • Don’t use any visual effects. By default on mac visual effects are enabled. That doesn’t make any sense if you have memory issues. Its better you make it off. Go to System Preferences -> Dock & untick Magnification. Also, change Minimise effect from Genie to Scale.

There are lots of software available in the market which offers to clean mac system & remove junk files, spam from the system. But I suggest the best way is to do it manually. As these are the automated systems & sometimes at taking remove important system file & keep you in more trouble.

Share
Share