zoul / lambda-alert Goto Github PK
View Code? Open in Web Editor NEWSimple UIAlertView wrapper that uses blocks for button actions.
Home Page: http://github.com/zoul/Lambda-Alert
License: MIT License
Simple UIAlertView wrapper that uses blocks for button actions.
Home Page: http://github.com/zoul/Lambda-Alert
License: MIT License
Better able to add to CocoaPods~
https://github.com/CocoaPods/CocoaPods
Hi there, nice work. I know that since iOS 8 UIAlertController is recommended. However in my project I would like to support iOS7 but also would like to use blocks in UIAlertView. Is iOS 7 supported within this library? Thanks.
Causes drawing issues and does not present full list of options
Source code of test view controller:
//
// HILIFieldMappingViewController.m
// ListIQ
//
// Created by Human Inference on 02/04/14.
// Copyright (c) 2014 Human Inference. All rights reserved.
//
#import "HILIFieldMappingViewController.h"
#import "CCActionSheet.h"
@interface HILIFieldMappingViewController ()
{
NSArray *dataArray;
NSArray *fieldNames;
NSArray *fieldSample;
NSArray *fieldTypes;
// UIPopoverController *poc;
}
@end
@implementation HILIFieldMappingViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
fieldTypes = @[@"Disregard this", @"Given name", @"Family name", @"Full name", @"Addressline",
@"City", @"State", @"Postal code", @"Country", @"Street", @"House number", @"Phone number", @"Fax number", @"Email", @"Website", @"Twitter ID", @"Facebook ID", @"LinkedIn ID", @"Record ID", @"Company", @"Gender", @"Age"];
fieldNames = @[
@"NAME",
@"ADDRESS_1",
@"ADDRESS_2",
@"ADDRESS_3",
@"ADDRESS_4",
@"CITY",
@"STATE",
@"POSTCODE",
@"COUNTRY"
];
fieldSample = @[
@"MS VIJAYA MAHESH SHARMA",
@"Perelsplatz 14-15",
@"APT # 806",
@"20 RIVER COURT",
@"",
@"Jersey City",
@"NJ",
@"7310",
@"US"
];
dataArray = @[
[[NSMutableArray alloc] initWithArray:@[
@"Full name",
@"Addressline",
@"Addressline",
@"Addressline",
@"Addressline",
@"City",
@"State",
@"Postal code",
@"Country"
]] ];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return dataArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
//Number of rows it should expect should be based on the section
/*
NSDictionary *dictionary = [dataArray objectAtIndex:section];
NSArray *array = [dictionary objectForKey:@"data"];
return [array count];
*/
NSArray *array = dataArray[section];
return [array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"FIELD_MAPPING";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
// Title is field name for index
cell.textLabel.text = [NSString stringWithFormat:@"%@ (sample value '%@')", fieldNames[indexPath.row], fieldSample[indexPath.row]];
NSArray *array = dataArray[indexPath.section];
NSString *cellValue = [array objectAtIndex:indexPath.row];
cell.detailTextLabel.text = cellValue;
return cell;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
NSArray *sections = @[@"Field mappings"];
if (section < sections.count) {
return sections[section];
}
return [NSString stringWithFormat:@"Unnamed section %ld", (long)section];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
CCActionSheet *sheet = [[CCActionSheet alloc] initWithTitle:[NSString stringWithFormat:@"Set field type for %@", fieldNames[indexPath.row]]];
NSMutableArray *currentFieldTypes = dataArray[0];
for (NSString *s in fieldTypes) {
[sheet addButtonWithTitle:s block:^{ currentFieldTypes[indexPath.row] = s; [tableView reloadData]; }];
}
[sheet addCancelButtonWithTitle:[NSString stringWithFormat:@"Leave '%@' as %@", fieldNames[indexPath.row], currentFieldTypes[indexPath.row]]];
CGRect aFrame = [tableView rectForRowAtIndexPath:indexPath];
[sheet showFromRect:aFrame inView:tableView animated:YES];
}
/*
#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.
}
*/
@end
Itβs very simple except the self-retaining trick. Maybe we can use a small retain cycle (strong-referenced id
property) to accomplish the trick?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.