-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aa10ff6
Showing
7 changed files
with
291 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2013-2014 Vincent Tourraine (http://www.vtourraine.net) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# VTAcknowledgementsViewController | ||
|
||
_Ready to use “Acknowledgements”/“Licenses” view controller for [CocoaPods](http://cocoapods.org/)._ | ||
|
||
## How to Install | ||
|
||
This project is only useful if you use CocoaPods, so let’s assume that you’re indeed using CocoaPods. | ||
|
||
1. Add `pod 'VTAcknowledgementsViewController'` in your `Podfile`. | ||
2. Import the `Pods-acknowledgements.plist` file from the generated `Pods` folder to your main app project (so you need to run `pod install` at least once before using this pod; don’t copy the file itself, just add a reference). | ||
|
||
**Note: if you know how to import this file automatically, as part of the `pod install` process, please let me know.** | ||
|
||
## How to Use | ||
|
||
The `VTAcknowledgementsViewController` instance is usually pushed to an existing `UINavigationController`. | ||
|
||
``` objc | ||
UIViewController *viewController = [VTAcknowledgementsViewController acknowledgementsViewController]; | ||
[self.navigationController pushViewController:viewController animated:YES]; | ||
``` | ||
## Requirements | ||
VTAcknowledgementsViewController requires iOS 5.0 and above, and uses ARC. | ||
## Credits | ||
VTAcknowledgementsViewController was created by [Vincent Tourraine](http://www.vtourraine.net). | ||
## License | ||
VTAcknowledgementsViewController is available under the MIT license. See the LICENSE file for more info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Pod::Spec.new do |s| | ||
s.name = 'VTAcknowledgementsViewController' | ||
s.version = '0.1' | ||
s.license = 'MIT' | ||
s.summary = 'Ready to use “Acknowledgements”/“Licenses” view controller for CocoaPods.' | ||
s.homepage = 'https://github.com/vtourraine/VTAcknowledgementsViewController' | ||
s.authors = { 'Vincent Tourraine' => 'me@vtourraine.net' } | ||
s.source = { :git => 'https://github.com/vtourraine/VTAcknowledgementsViewController.git', :tag => '0.1' } | ||
s.source_files = 'VTAcknowledgementsViewController/*.{h,m}' | ||
s.public_header_files = 'VTAcknowledgementsViewController/VTAcknowledgementsViewController.{h,m}' | ||
s.requires_arc = true | ||
|
||
s.ios.deployment_target = '5.0' | ||
end |
31 changes: 31 additions & 0 deletions
31
VTAcknowledgementsViewController/VTAcknowledgementViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// VTAcknowledgementViewController.h | ||
// | ||
// Copyright (c) 2013-2014 Vincent Tourraine (http://www.vtourraine.net) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface VTAcknowledgementViewController : UIViewController | ||
|
||
- (id)initWithTitle:(NSString *)title text:(NSString *)text; | ||
|
||
@end | ||
|
56 changes: 56 additions & 0 deletions
56
VTAcknowledgementsViewController/VTAcknowledgementViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// VTAcknowledgementViewController.m | ||
// | ||
// Copyright (c) 2013-2014 Vincent Tourraine (http://www.vtourraine.net) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import "VTAcknowledgementViewController.h" | ||
|
||
@interface VTAcknowledgementViewController () | ||
|
||
@property (nonatomic, copy) NSString *text; | ||
|
||
@end | ||
|
||
|
||
@implementation VTAcknowledgementViewController | ||
|
||
- (id)initWithTitle:(NSString *)title text:(NSString *)text | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
self.title = title; | ||
self.text = text; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)loadView | ||
{ | ||
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectZero]; | ||
textView.alwaysBounceVertical = YES; | ||
textView.font = [UIFont systemFontOfSize:16]; | ||
textView.text = self.text; | ||
|
||
self.view = textView; | ||
} | ||
|
||
@end |
36 changes: 36 additions & 0 deletions
36
VTAcknowledgementsViewController/VTAcknowledgementsViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// VTAcknowledgementsViewController.h | ||
// | ||
// Copyright (c) 2013-2014 Vincent Tourraine (http://www.vtourraine.net) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface VTAcknowledgementsViewController : UITableViewController | ||
|
||
/* | ||
Creates a new acknowledgements view controller | ||
*/ | ||
+ (instancetype)acknowledgementsViewController; | ||
|
||
- (id)initWithAcknowledgementsPlistPath:(NSString *)acknowledgementsPlistPath; | ||
|
||
@end | ||
|
102 changes: 102 additions & 0 deletions
102
VTAcknowledgementsViewController/VTAcknowledgementsViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// | ||
// VTAcknowledgementsViewController.m | ||
// | ||
// Copyright (c) 2013-2014 Vincent Tourraine (http://www.vtourraine.net) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import "VTAcknowledgementsViewController.h" | ||
#import "VTAcknowledgementViewController.h" | ||
|
||
@interface VTAcknowledgementsViewController () | ||
|
||
@property (nonatomic, strong) NSArray *acknowledgements; | ||
|
||
@end | ||
|
||
|
||
@implementation VTAcknowledgementsViewController | ||
|
||
+ (instancetype)acknowledgementsViewController | ||
{ | ||
NSString *path = [[NSBundle mainBundle] pathForResource:@"Pods-acknowledgements" ofType:@"plist"]; | ||
return [[VTAcknowledgementsViewController alloc] initWithAcknowledgementsPlistPath:path]; | ||
} | ||
|
||
- (id)initWithAcknowledgementsPlistPath:(NSString *)acknowledgementsPlistPath | ||
{ | ||
self = [super initWithStyle:UITableViewStyleGrouped]; | ||
if (self) { | ||
NSDictionary *root = [NSDictionary dictionaryWithContentsOfFile:acknowledgementsPlistPath]; | ||
self.acknowledgements = root[@"PreferenceSpecifiers"]; | ||
if (self.acknowledgements.count >= 2) { | ||
// Remove the header and footer | ||
self.acknowledgements = [self.acknowledgements subarrayWithRange:NSMakeRange(1, self.acknowledgements.count - 2)]; | ||
} | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
self.title = NSLocalizedString(@"Acknowledgements", nil); | ||
|
||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; | ||
label.text = [NSLocalizedString(@"Generated by CocoaPods - http://cocoapods.org", nil) stringByAppendingString:@"\n \n "]; | ||
label.font = [UIFont systemFontOfSize:12]; | ||
label.textColor = [UIColor grayColor]; | ||
label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; | ||
[label sizeToFit]; | ||
|
||
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(label.frame), 80)]; | ||
[footerView addSubview:label]; | ||
label.frame = CGRectMake(0, 22, | ||
CGRectGetWidth(label.frame), CGRectGetHeight(label.frame)); | ||
self.tableView.tableFooterView = footerView; | ||
} | ||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section | ||
{ | ||
return self.acknowledgements.count; | ||
} | ||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; | ||
if (!cell) { | ||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; | ||
} | ||
|
||
NSDictionary *preferenceSpecifier = self.acknowledgements[indexPath.row]; | ||
cell.textLabel.text = preferenceSpecifier[@"Title"]; | ||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; | ||
|
||
return cell; | ||
} | ||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
NSDictionary *preferenceSpecifier = self.acknowledgements[indexPath.row]; | ||
VTAcknowledgementViewController *viewController = [[VTAcknowledgementViewController alloc] initWithTitle:preferenceSpecifier[@"Title"] text:preferenceSpecifier[@"FooterText"]]; | ||
[self.navigationController pushViewController:viewController animated:YES]; | ||
} | ||
|
||
@end |