iOS 10 tutorial : Working with collection view

Collection view is very good component of IOS . Its similar with table but have some basic difference . Here I will discuss with ios Collection view with easy way ūüôā

So let start ,

Part 1 :

Create a project Named Like CollectionViewDemo . Go to Main.Storyboard and add a Navigation controller – for that go to Editor menu of toolbar and select EmbededIn and click Navigation Controller . It will add a Navigation bar of the top of the Story Board . Click that and named the text as Collection Demo or as you like .

 

Then the UI main part is coming , first choose CollectionView from library and add it to srory board make it full screen and now select a collection row and make its size as 90/90 .

Now drag an Imagview from library and drop it to collection cell , make it fill as cell size . and make it aspect fill . OK?

Part : 2

Create A Cocoa touch file named MyCollectionViewCell .

Now goto main.storyboard and select collection cell and In class file attach MyCollectionViewCell file then identify is as  Рcollection_cell

 

Now return to MyCollectionViewCell and drag collection_cell into MyCollectionViewCell and named it as MyCollectionView . Ok?

 

Part 3 :

 

Now add some Image file into asset folder

Go to ViewController class and drag CollectionView to ViewController and named it ass MyCollectionView

@IBOutlet weak var MyCollectionView: UICollectionView!

and images listed as array like

var images = [“one”,”two”,”three”,”four”, “five”]

make all class as

[java]
//
// ViewController.swift
// IOSCollectionView
//
// Created by Arif on 11/24/16.
// Copyright © 2016 Arif. All rights reserved.
//</code>

class ViewController: UIViewController , UICollectionViewDataSource , UICollectionViewDelegate{
@IBOutlet weak var MyCollectionView: UICollectionView!

var images = ["one","two","three","four", "five"]

override func viewDidLoad() {
super.viewDidLoad()
self.MyCollectionView.delegate = self
self.MyCollectionView.dataSource = self

}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

return images.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "collection_cell", for: indexPath) as! MyCollectionViewCell
cell.MyImageView.image = UIImage(named: images[indexPath.row])
return cell

}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print("selected item is ", indexPath.row)
}
}

[/java]

run it —

Working With ionic and cordova : Part-1 Installation

Ionic is a good platform for hybrid mobile apps development , both for android and ios . There has some good stuffs and good functionality . We can make app only with HTML , CSS , And java Script framework like angular , and we can use a marketing company as The Indexer to promote these sites or apps.

So lets start –

Step : 1

Fist of all we have to install node js of our machine . Go the node js website and download and install it .

https://nodejs.org/en/

Step : 2

From this step we can follow the ionic docs from here https://ionicframework.com/getting-started/

to install ionic and cordova first open your cmd prompt for windows and terminal for mac and linux

then paste it and enter

npm install -g cordova ionic

it will make insure to install ionic and cordova

Step:3

Now go you drive where you want to create  project

like i have made a folder on O Drive and name the folder is “ionic Projects”

the go there from cmd as

cd O:

cd ionic Projects/

and

ionic start myApp tabs

it will create a tab based project named “myApp”

step : 4

To Build and Run project for android

cd myApp
ionic platform add Android
ionic build Android
ionic emulate Android

if every thing is ok then it will show the following type of project on emulator

capture

Binary Search : Deep knowledge with Java

[java]
import java.util.Scanner;

class BinarySearch
{
public static void main(String args[])
{
int c, first, last, middle, n, search, array[];

Scanner in = new Scanner(System.in);
System.out.println("Enter number of elements");
n = in.nextInt();
array = new int[n];

System.out.println("Enter " + n + " integers");

for (c = 0; c < n; c++)
array[c] = in.nextInt();

System.out.println("Enter value to find");
search = in.nextInt();

first = 0;
last = n – 1;
middle = (first + last)/2;

while( first <= last )
{
if ( array[middle] < search ) first = middle + 1;
else if ( array[middle] == search ) { System.out.println(search + " found at location " + (middle + 1) + "."); break;
} else last = middle – 1;

middle = (first + last)/2;
}

if ( first > last )
System.out.println(search + " is not present in the list.\n");
}
}
[/java]