NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//
// MyCollectionViewController.m
// _CollectionView
//
// Created by STU 26 on 3/27/17.
// Copyright (c) 2017 STU 26. All rights reserved.
//

#import "MyCollectionViewController.h"
#import "MyCollectionViewCell.h"
#import <AVFoundation/AVFoundation.h>
const NSTimeInterval kAnimationDuration=0.20;

@interface MyCollectionViewController ()<AVAudioPlayerDelegate>
@property (nonatomic,strong) AVAudioPlayer *audioPlayer;
@property (nonatomic,strong) NSArray *notalar ;

@end

@implementation MyCollectionViewController

static NSString * const reuseIdentifier = @"Cell";
-(void) collectionView:(UICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *selectedViewCell=[collectionView cellForItemAtIndexPath:indexPath];
[UIView animateWithDuration:kAnimationDuration animations:^{
selectedViewCell.transform=CGAffineTransformMakeScale(2.0f, 2.0f);
}];
}

-(void) collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *selectedViewCell=[collectionView cellForItemAtIndexPath:indexPath];
[UIView animateWithDuration:kAnimationDuration animations:^{
selectedViewCell.transform=CGAffineTransformMakeScale(1.0f, 1.0f);
dispatch_queue_t dispatchQueue=dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);

dispatch_async(dispatchQueue, ^(void){

NSBundle *mainBundle=[NSBundle mainBundle];
NSString *filePath=[mainBundle pathForResource:[NSString stringWithFormat:@"%@",self.notalar [(long)indexPath.row]] ofType:@"mp3"];
NSData *fileData=[NSData dataWithContentsOfFile:filePath];
NSError *error=nil;
self.audioPlayer=[[AVAudioPlayer alloc] initWithData:fileData error:&error];
if (self.audioPlayer!=nil) {
self.audioPlayer.delegate=self;
if ([self.audioPlayer prepareToPlay] && [self.audioPlayer play]) {
/* Başarılıdır */
} else {
/* Bşarısız */
}
}else{
/* AudioPlayer oluşturulmamış... */
}
});
}];
}

-(void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *selectedCell=[collectionView cellForItemAtIndexPath:indexPath];
[UIView animateWithDuration:kAnimationDuration animations:^{
selectedCell.alpha=0.0f;
} completion:^(BOOL finished) {
[UIView animateWithDuration:kAnimationDuration animations:^{
selectedCell.alpha=1.0f;
}];
}];
}


-(NSArray *) allImages{
static NSArray *AllSectionImages=nil;
if (AllSectionImages==nil) {
AllSectionImages=@[[UIImage imageNamed:@"11"],[UIImage imageNamed:@"22"],[UIImage imageNamed:@"33"]];
}
return AllSectionImages;
}

-(UIImage *) ramdomImage{
return [self allImages][arc4random_uniform((int)[self allImages].count)];
}

-(instancetype) initWithCollectionViewLayout:(UICollectionViewLayout *)layout{
self=[super initWithCollectionViewLayout:layout];
if (self!=nil) {

UINib *nib=[UINib nibWithNibName:NSStringFromClass([MyCollectionViewCell class]) bundle:[NSBundle mainBundle]];

[self.collectionView registerNib:nib forCellWithReuseIdentifier:reuseIdentifier];
}
return self;
}

- (void)viewDidLoad {
[super viewDidLoad];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
self.collectionView.backgroundColor=[UIColor whiteColor];
self.notalar = @[@"doo", @"faa", @"laa",@"mii", @"ree", @"soll"];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

#pragma mark <UICollectionViewDataSource>

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1+arc4random_uniform(1);
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 6+arc4random_uniform(1);
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

MyCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];


cell.imageViewBackgroundImage.image=[self ramdomImage];
cell.imageViewBackgroundImage.contentMode=UIViewContentModeScaleToFill;
cell.labelText.text = [NSString stringWithFormat:@"%@",self.notalar [(long)indexPath.row]];

return cell;
}

#pragma mark <UICollectionViewDelegate>

/*
// Uncomment this method to specify if the specified item should be highlighted during tracking
- (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
*/

/*
// Uncomment this method to specify if the specified item should be selected
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
*/

/*
// Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item
- (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}

- (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {
return NO;
}

- (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender {

}
*/

@end
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.