diff --git a/UIBubbleTableView.podspec b/UIBubbleTableView.podspec new file mode 100644 index 0000000..fdb9fb7 --- /dev/null +++ b/UIBubbleTableView.podspec @@ -0,0 +1,14 @@ +Pod::Spec.new do |s| + s.name = "UIBubbleTableView" + s.version = "0.2.1" + s.summary = "Cocoa UI component for chat bubbles with avatars and images support." + s.homepage = "http://alexbarinov.github.com/UIBubbleTableView/" + s.license = { + :type => 'Creative Commons Attribution 3.0 Unported License', + :text => 'This work is licensed under the Creative Commons Attribution 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.' + } + s.author = { "Alex Barinov" => "github@alex.barinov.name" } + s.source = { :git => "https://github.com/fuJiin/UIBubbleTableView.git" } + s.source_files = 'src/**/*.{h,m}' + s.resources = "images/*.png" +end diff --git a/example/Default-568h@2x.png b/example/Default-568h@2x.png new file mode 100644 index 0000000..0891b7a Binary files /dev/null and b/example/Default-568h@2x.png differ diff --git a/example/UIBubbleTableViewExample.xcodeproj/project.pbxproj b/example/UIBubbleTableViewExample.xcodeproj/project.pbxproj index 5aff5b7..ffebd0b 100644 --- a/example/UIBubbleTableViewExample.xcodeproj/project.pbxproj +++ b/example/UIBubbleTableViewExample.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ 76ED208715BF09E300E186D3 /* UIBubbleTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 76ED208615BF09E300E186D3 /* UIBubbleTableView.m */; }; 76ED208B15BF0BB100E186D3 /* NSBubbleData.m in Sources */ = {isa = PBXBuildFile; fileRef = 76ED208A15BF0BB100E186D3 /* NSBubbleData.m */; }; 76ED209415BF29EE00E186D3 /* UIBubbleTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 76ED209315BF29EE00E186D3 /* UIBubbleTableViewCell.m */; }; + 83DDB83E18777872001D626D /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 83DDB83D18777872001D626D /* Default-568h@2x.png */; }; C836D5CA1625CBA5004CB4A9 /* missingAvatar.png in Resources */ = {isa = PBXBuildFile; fileRef = C836D5C81625CBA5004CB4A9 /* missingAvatar.png */; }; C836D5CB1625CBA5004CB4A9 /* missingAvatar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C836D5C91625CBA5004CB4A9 /* missingAvatar@2x.png */; }; C836D5CE1625D718004CB4A9 /* avatar1.png in Resources */ = {isa = PBXBuildFile; fileRef = C836D5CD1625D718004CB4A9 /* avatar1.png */; }; @@ -62,6 +63,7 @@ 76ED208A15BF0BB100E186D3 /* NSBubbleData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NSBubbleData.m; path = ../../src/NSBubbleData.m; sourceTree = ""; }; 76ED209215BF29EE00E186D3 /* UIBubbleTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UIBubbleTableViewCell.h; path = ../../src/UIBubbleTableViewCell.h; sourceTree = ""; }; 76ED209315BF29EE00E186D3 /* UIBubbleTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UIBubbleTableViewCell.m; path = ../../src/UIBubbleTableViewCell.m; sourceTree = ""; }; + 83DDB83D18777872001D626D /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; C836D5C81625CBA5004CB4A9 /* missingAvatar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = missingAvatar.png; sourceTree = ""; }; C836D5C91625CBA5004CB4A9 /* missingAvatar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "missingAvatar@2x.png"; sourceTree = ""; }; C836D5CD1625D718004CB4A9 /* avatar1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = avatar1.png; sourceTree = SOURCE_ROOT; }; @@ -94,6 +96,7 @@ 76ED205315BF096C00E186D3 = { isa = PBXGroup; children = ( + 83DDB83D18777872001D626D /* Default-568h@2x.png */, 76ED206815BF096C00E186D3 /* UIBubbleTableViewExample */, 76ED206115BF096C00E186D3 /* Frameworks */, 76ED205F15BF096C00E186D3 /* Products */, @@ -242,6 +245,7 @@ C83B107A15DE43180067DADE /* bubbleMine@2x.png in Resources */, C83B107B15DE43180067DADE /* bubbleSomeone.png in Resources */, C83B107C15DE43180067DADE /* bubbleSomeone@2x.png in Resources */, + 83DDB83E18777872001D626D /* Default-568h@2x.png in Resources */, C83B107D15DE43180067DADE /* typingMine.png in Resources */, C83B107E15DE43180067DADE /* typingMine@2x.png in Resources */, C83B107F15DE43180067DADE /* typingSomeone.png in Resources */, diff --git a/example/UIBubbleTableViewExample/ViewController.m b/example/UIBubbleTableViewExample/ViewController.m index 5516175..b3a2ff6 100644 --- a/example/UIBubbleTableViewExample/ViewController.m +++ b/example/UIBubbleTableViewExample/ViewController.m @@ -82,7 +82,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface #pragma mark - UIBubbleTableViewDataSource implementation -- (NSInteger)rowsForBubbleTable:(UIBubbleTableView *)tableView +- (NSUInteger)rowsForBubbleTable:(UIBubbleTableView *)tableView { return [bubbleData count]; } diff --git a/src/NSBubbleData.m b/src/NSBubbleData.m index 5a39821..be13efd 100644 --- a/src/NSBubbleData.m +++ b/src/NSBubbleData.m @@ -54,7 +54,7 @@ + (id)dataWithText:(NSString *)text date:(NSDate *)date type:(NSBubbleType)type - (id)initWithText:(NSString *)text date:(NSDate *)date type:(NSBubbleType)type { UIFont *font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; - CGSize size = [(text ? text : @"") sizeWithFont:font constrainedToSize:CGSizeMake(220, 9999) lineBreakMode:NSLineBreakByWordWrapping]; + CGSize size = [(text ? text : @"") boundingRectWithSize: CGSizeMake(220, 9999) options: NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName:font }context: nil].size; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)]; label.numberOfLines = 0; diff --git a/src/UIBubbleTableView.m b/src/UIBubbleTableView.m index 29e4ddb..4ea1f34 100644 --- a/src/UIBubbleTableView.m +++ b/src/UIBubbleTableView.m @@ -95,7 +95,7 @@ - (void)reloadData self.bubbleSection = nil; // Loading new data - int count = 0; + NSUInteger count = 0; #if !__has_feature(objc_arc) self.bubbleSection = [[[NSMutableArray alloc] init] autorelease]; #else @@ -156,7 +156,7 @@ - (void)reloadData - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - int result = [self.bubbleSection count]; + NSInteger result = [self.bubbleSection count]; if (self.typingBubble != NSBubbleTypingTypeNobody) result++; return result; } @@ -169,7 +169,7 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger return [[self.bubbleSection objectAtIndex:section] count] + 1; } -- (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { // Now typing if (indexPath.section >= [self.bubbleSection count]) diff --git a/src/UIBubbleTableViewDataSource.h b/src/UIBubbleTableViewDataSource.h index 01194e7..7ee03af 100644 --- a/src/UIBubbleTableViewDataSource.h +++ b/src/UIBubbleTableViewDataSource.h @@ -18,7 +18,7 @@ @required -- (NSInteger)rowsForBubbleTable:(UIBubbleTableView *)tableView; +- (NSUInteger)rowsForBubbleTable:(UIBubbleTableView *)tableView; - (NSBubbleData *)bubbleTableView:(UIBubbleTableView *)tableView dataForRow:(NSInteger)row; @end