From 22d2e338c5ce42b541e1e006ec9ab08937d63e0a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 3 Jan 2014 17:09:54 -0600 Subject: [PATCH 1/3] A few changes to improve compatibility --- example/Default-568h@2x.png | Bin 0 -> 18594 bytes .../UIBubbleTableViewExample/ViewController.m | 2 +- src/UIBubbleTableView.m | 6 +++--- src/UIBubbleTableViewDataSource.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 example/Default-568h@2x.png diff --git a/example/Default-568h@2x.png b/example/Default-568h@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0891b7aabfcf3422423b109c8beed2bab838c607 GIT binary patch literal 18594 zcmeI4X;f257Jx&9fS`ixvS;&$x8J@slQFSel)6zJN=?13FB7H(lQjRkSy8x_-S~tvu2gzn1oS+dLcF#eqtq$ z%tf9TTvX?`)R@}3uBI;jzS-=ZR-Td&MHaS&;!0?Ni*#$#`n*~CcQK)Q9vAQ~TUpnI!j)a2biYK^R)M~A5wUDZhx?ULMX z3x1P&qt=trOY6P2U67L=m=U?F|5#Uj(eCueNTZaHs_ceWiHeET+j+tp3Jt9g(ekqP z2WOvfR{qV+9r+o4J5?qK>7;;^+I7tGv-i)es$X_D=EoKF+S?zsyj^oRFElP}c}JT< zd8SUs-?O?}2YD#ngKbnHgzHBcboxK_2r9l(?eNCl-pEzkJm}fY?WC*jnS?VBE4EpY zO$fEejz6fU;W2Kl>JeQBZBl-%Irg`obSlg*@4QB;Dd1H7^Oi5wvt4d{RZ!8Og?^aE z)k0$1g+V3fd(gdQ3d&q2q-FL*uy#}|bc^=VhFsl0jBgUGJ+-s3U8MK9A!YJJMxpci z5hJ%|{DwV48fZn0{n5l$N_KcSb#NKE4plB`9I6Zt=Z!~-zw0{9tg$L&Ju1F0X)Cy8 zKF;(&lJ>x)Jw(=;p~sF(Sd9VWGwFE2rnyS9!f^DZ8+aCLq zQ};>lcJ1GDLqjm6Hd>|Eabno@P`~Bn(~6^aD_#yoEH(a?Nm1S<;S+hSxI5d16^<1lEM3NPFi zkqPrpL)+ zgnseFikg`gJVBha1&7C4;O6>h=dt~`ND+;Zd?W(4v2JIb7Pt>Td42%M-Ju-XAH#Pns762L}K3 zDhvsRqN0Ni(1UrishD2YvV?4*h2iFj$+&N||Fn$4n|^NSU+o?~jq`0jVQt8T9l{7b zXiwwODFh2V!Q6sqP9S>WH$oOf$N~=d0-bqTlD61!=`&0eAP-F>XN?*|gtOXX{ zQVTWyYo4ZK0GAw!GHf|pz9`D;-bbb*5LBX*{bnz|+)$@&P9|ORM2o?95{;ejvo&r- zq8cBhTN6nn)7~W>54U)%-F_-b?YKdfk5I8MHcuzBD5)!;yv#Z&R&^y=@=>VTIMy#r zX&U<=BsPkdqcMe<_}2+>H%XKyrr5ZR8_KVe>ZqYN z^=^~TFD};;rHJ$U;{~w^hYojl4hRI@SH$^K{YEo=sg)WY87r!*7blQK&qnpDo0`Vn zkl)9u9g=mCh&ZCJS(L4yN3k0kQ zuvg$h2KEEk51T+O0JQ+r0`R>g{jvqM0Mr6d3qUOZwE!?PI7HY@CE|dr sfw?Q;rAv?G4&^^8-z_>&sWXMxvD*gPOU4CBe-*@OtE+wfmVJNyHv)PfH~;_u literal 0 HcmV?d00001 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/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 From 5d54a69f37fac3ad06c07e35da8bb0b80cb0d708 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 5 Jan 2014 21:42:35 -0600 Subject: [PATCH 2/3] merges in pod spec from fuJiin/UIBubbleTableView --- UIBubbleTableView.podspec | 14 ++++++++++++++ .../project.pbxproj | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 UIBubbleTableView.podspec 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/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 */, From 8e26b71266d2bdeef322c131ca3ee5dbbfd0536f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 5 Jan 2014 22:17:41 -0600 Subject: [PATCH 3/3] stops using deprecated method. This fix is only compatible with iOS 7 or later. --- src/NSBubbleData.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;