Carousel View

iCarousel

I wanted to add an animation when dismissing, a button at the top and bottom of the view, one to dismiss, one to save, and move off in that direction.

MDCSwipeToChoose

TinderSimpleSwipeCards

@clsource added other directions

Directions

Jam Jar Cinema Wallet Passes

 

My local cinema is Awesome!

I want to create passes to keep a memento of the films I’ve seen. I order online so don’t get ticket stubs from the venue and I like having a digital copy, like CineWorld does.

 

There are a number of websites which allow you to make Wallet Passes.

I’ve recently tried PassSlot (https://www.passslot.com).

PassSlot

It has a free tier which allows you to create 1 PassID, multiple templates, and a set limit of passes, which is all I need.

It has an SDK which is great.

I created my Template with variables for the various pieces of information and now I have an iOS app which allows me to fill in the values, pick an image and create a pass.

It uses the iTunes Artwork Finder from Ben Dodson.

 Wallet


I’d started making a Mac app to create Wallet Passes.

I followed the RW tutorials on PassKit but my PHP was rusty so never got that side working.

I got the local one working which used the sign tool and created all the files

  • pass.json
  • manifest.json
  • .pkpass
  • etc

JJC Passes (Mac) (1)

But when I tried to add them to my phone I ran into issues, I raised a bug will Apple and they are working on something.

The pass has to be served over SSL.

I made my own Contact Card: https://alexhedley.wordpress.com/2014/12/29/passbook/

Custom UIAlertController in Objc

 

Custom UIAlertController in Objc

 

You can change the background colour of the Alert too.

Change the colour of added controls like UITextField too!

Links

Hacking UIAlertController in Swift.
https://iosdevcenters.blogspot.com/2016/05/hacking-uialertcontroller-in-swift.html

UIAlertController custom font, size, color
http://stackoverflow.com/a/26530577/2895831

XLForm

XLForm is the most flexible and powerful iOS library to create dynamic table-view forms. The goal of the library is to get the same power of hand-made forms but spending 1/10 of the time.

Image

Add an image to the left of a form input

row = [XLFormRowDescriptor formRowDescriptorWithTag:@"fullname" rowType:XLFormRowDescriptorTypeText];
[row.cellConfigAtConfigure setObject:@"Full Name" forKey:@"textField.placeholder"];
[row.cellConfigAtConfigure setObject:[UIImage imageNamed:@"User"] forKey:@"imageView.image"];
[section addFormRow:row];

Buttons

XLFormRowDescriptor *buttonRow = [XLFormRowDescriptor formRowDescriptorWithTag:kButton rowType:XLFormRowDescriptorTypeButton title:@"A 6 digit verification code has been sent via SMS"];
[buttonRow.cellConfig setObject:[UIColor purpleColor] forKey:@"textLabel.color"];
[buttonRow.cellConfig setObject:[UIFont fontWithName:kFont size:10] forKey:@"textLabel.font"];
buttonRow.cellStyle = UITableViewCellStyleValue1;
buttonRow.value = @"Enter Code";
buttonRow.action.formSelector = @selector(didTouchButton:);
[section addFormRow:buttonRow];

Screenshot

Register


Switch

To turn the switch on

row = [XLFormRowDescriptor formRowDescriptorWithTag:@"switch" rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"Boolean"];
row.value = @1;

Issues

I raised an issue about the Floating Label covering the Image.

Register - JVFloatLabeledTextField (2)

A very quick reply to update

- (NSArray *)layoutConstraints

I added the following:

const static CGFloat kHMargin = 50.0f;
NSDictionary *metrics = @{@"vMargin":@(kVMargin), @"hMargin":@(kHMargin)};
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(hMargin)-[floatLabeledTextField]-|" options:0 metrics:metrics views:views]];

Register - JVFloatLabeledTextField (4)


Cell Separator

Add in ‘viewDidLoad’

self.tableView.separatorColor = [UIColor redColor];

Register - JVFloatLabeledTextField (5)


Section Background Colour

I wished to change the Header/Footer background colour.

Code

- (void)viewDidLoad {
    [[self tableView] registerClass:[UITableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"headerFooterReuseIdentifier"];
}

Header

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UITableViewHeaderFooterView *headerFooterView = [[self tableView] dequeueReusableHeaderFooterViewWithIdentifier:@"headerFooterReuseIdentifier"];
    headerFooterView.contentView.backgroundColor = kBackgroundColor;

    return headerFooterView;
}

Footer

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UITableViewHeaderFooterView *headerFooterView = [[self tableView] dequeueReusableHeaderFooterViewWithIdentifier:@"headerFooterReuseIdentifier"];
    headerFooterView.contentView.backgroundColor = kBackgroundColor;

    return headerFooterView;
}

FloatLabeledTextFieldCell

Floating Label

There is a property on the TextField you can set to change the colour of the Floating Label

  • floatingLabelActiveTextColor
[row.cellConfig setObject:[UIColor redColor] forKey:@"floatLabeledTextField.floatingLabelActiveTextColor"];

TextField

If you want to change the TextField text colour:

[row.cellConfig setObject:[UIColor whiteColor] forKey:@"floatLabeledTextField.textColor"];

Register - JVFloatLabeledTextField (5)

Didn’t change anything:

[row.cellConfig setObject:[UIColor greenColor] forKey:@"textLabel.highlightedTextColor"];

Or

[row.cellConfig setObject:[UIColor redColor] forKey:@"floatLabeledTextField.floatingLabel.textColor"];

Image

Set the “imageView.tintColor”

[row.cellConfigAtConfigure setObject:[UIColor whiteColor] forKey:@"imageView.tintColor"];

Register - JVFloatLabeledTextField (6)


Accessory

- (UIView *)inputAccessoryViewForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor
{
      return nil; //will hide it completely
      // You can use the rowDescriptor parameter to hide/customize the accessory view for a particular rowDescriptor type.
}

 

Without reading the documentation!!

Adding a Checkmark

XLFormRowDescriptor *row = [XLFormRowDescriptor formRowDescriptorWithTag:@"Check" rowType:XLFormRowDescriptorTypeBooleanCheck title:NSLocalizedString(@"Check", nil)];
[newSection addFormRow:row];

Swap to a different image

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Circle"]];
imageView.tintColor = [UIColor redColor];
[row.cellConfig setObject:imageView forKey:@"accessoryView"];

Now to handle the toggling…

This method isn’t being called.

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"Tapped");
}

 


Dynamically Adding Rows

I’m using segues to move between views.

I’m setting a property – an array of items in the ‘prepareForSegue’.

But ‘initWithCoder’ doesn’t have these values set yet.

‘viewDidLoad’ does so call a method there.

Create your Form, Section(s) and Row(s) in the interface and use them:

[section addFormRow:row beforeRow:buttonRow];

Selected Row Label colour

Tried a couple of options:

[row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.highlightedTextColor"];

And

[row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.tintColor"];

 


Change the cursor colour

  • textField.tintColor
[row.cellConfig setObject:[UIColor greenColor] forKey:@"textField.tintColor"];

Register - JVFloatLabeledTextField (7)

 


 


Alternatives

UISwitch

Changing the colour of a UISwitch control.

#define kSwitchOnColor [UIColor colorWithRed:0.647 green:0.757 blue:0.463 alpha:1] // /*#A5C176*/ Green

#define kSwitchOffColor [UIColor colorWithRed:0.29 green:0.29 blue:0.525 alpha:1]; // /*#4A4A86*/ Purple
UISwitch *switchview = [[UISwitch alloc] initWithFrame:CGRectZero];
[switchview setOn:TRUE animated:YES];
switchview.onTintColor = kSwitchOnColor;
switchview.tintColor = kSwitchOffColor;
//tintColor just does outline
switchview.backgroundColor = kSwitchOffColor;
switchview.layer.cornerRadius = 16.0f;

tintColor changes the background when sliding but when off just has the outline, if you change the background then it is square so add a corner radius.

API Clients – Chaining Requests

POSTMAN

https://www.getpostman.com/docs/chaining_requests

http://blog.getpostman.com/2014/01/27/extracting-data-from-responses-and-chaining-requests/

var jsonData = JSON.parse(responseBody);

postman.setEnvironmentVariable("token", jsonData.token);

 

Add

{{token}}

PAW

Variables from previous responses

https://paw.cloud/docs/environments/environments-from-responses

In the response view, right-click on the field you’re interested in and pick Copy as Response Body Dynamic Value

Swift Package Manager Notes

I’ve been running through the excellent tutorials from NSScreencast (@NSScreencast) on using the swift package manager.

I’ve ran into a couple of issues which I thought I’d share as others might also run into them and hopefully they will be of use.

Thanks to subdigital for the help whilst I’m learning.

I had a couple of issues with some gems in Ruby since macOS comes shipped with a lesser version.

Setup: https://gorails.com/setup/osx/10.12-sierra

Reboot once completed.

Next when I went to complete the second video in the series I’d realised I hadn’t set up a great folder structure.

I had Katas then the code I’d been working with for the first FizzBuzz, this really needs it’s own folder, I moved this over then made a copy for the updates to guard, should really be using source control but I haven’t for now.

I tried running

bundle exec guard init
bundle exec guard

But got an error when I tried updating any of the code

<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/AlexHedley/Documents/NSScreencast/Katas/FizzBuzz/.build/debug.yaml test
Failed

I asked ben for help and he pointed me in the right direction, this wasn’t an issue with ruby but with swift.

I ran

swift build

and got a better error to work with

:0: error: PCH was compiled with module cache path '/Users/AlexHedley/Documents/NSScreencast/Katas/.build/debug/ModuleCache/Q3KKH3V7UU86', but the path is currently '/Users/AlexHedley/Documents/NSScreencast/Katas/FizzBuzz Updated/.build/debug/ModuleCache/Q3KKH3V7UU86'

Looking around I found that I needed to delete the .build folder

http://stackoverflow.com/a/410…

then I ran

swift build
bundle exec guard init
bundle exec guard
 and everything was working.

Other things I looked at

Command-Option-Shift-K to clean out the build folder. Even better, quit Xcode and clean out ~/Library/Developer/Xcode/DerivedData

http://stackoverflow.com/quest…

Would it be worth deleting the ModuleCache folder
/Users/AlexHedley/Library/Developer/Xcode/DerivedData/ModuleCache
http://meandmark.com/blog/2016…

Usually it can be resolved by holding down the Option key and choosing Product > Clean Build Folder…

http://stackoverflow.com/a/154…
Is there a way to do this for what we are using?


Completed Tutorials