diff --git a/ASHMessageTableViewDemo.xcodeproj/project.pbxproj b/ASHMessageTableViewDemo.xcodeproj/project.pbxproj index 28ef975..315887d 100644 --- a/ASHMessageTableViewDemo.xcodeproj/project.pbxproj +++ b/ASHMessageTableViewDemo.xcodeproj/project.pbxproj @@ -15,6 +15,31 @@ A97429BB1A68C81C00732735 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = A97429B91A68C81C00732735 /* LaunchScreen.xib */; }; A97429C71A68C81C00732735 /* ASHMessageTableViewDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A97429C61A68C81C00732735 /* ASHMessageTableViewDemoTests.m */; }; A9B965551A6D307B0017F9F2 /* MessageTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B965541A6D307B0017F9F2 /* MessageTableView.m */; }; + A9B965A61A6D35300017F9F2 /* NSString+DocumentPath.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B965961A6D35300017F9F2 /* NSString+DocumentPath.m */; }; + A9B965A71A6D35300017F9F2 /* UIImage+StrethImage.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B965981A6D35300017F9F2 /* UIImage+StrethImage.m */; }; + A9B965A81A6D35300017F9F2 /* ChartCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9659B1A6D35300017F9F2 /* ChartCell.m */; }; + A9B965A91A6D35300017F9F2 /* ChartCellFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B9659D1A6D35300017F9F2 /* ChartCellFrame.m */; }; + A9B965AA1A6D35300017F9F2 /* ChartMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B965A01A6D35300017F9F2 /* ChartMessage.m */; }; + A9B965AB1A6D35300017F9F2 /* ChartContentView.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B965A31A6D35300017F9F2 /* ChartContentView.m */; }; + A9B965AC1A6D35300017F9F2 /* KeyBordVIew.m in Sources */ = {isa = PBXBuildFile; fileRef = A9B965A51A6D35300017F9F2 /* KeyBordVIew.m */; }; + A9B965C01A6D35820017F9F2 /* chat_bg_default.jpg in Resources */ = {isa = PBXBuildFile; fileRef = A9B965AE1A6D35820017F9F2 /* chat_bg_default.jpg */; }; + A9B965C11A6D35820017F9F2 /* chat_bottom_keyboard_nor.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965AF1A6D35820017F9F2 /* chat_bottom_keyboard_nor.png */; }; + A9B965C21A6D35820017F9F2 /* chat_bottom_keyboard_press.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B01A6D35820017F9F2 /* chat_bottom_keyboard_press.png */; }; + A9B965C31A6D35820017F9F2 /* chat_bottom_smile_nor.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B11A6D35820017F9F2 /* chat_bottom_smile_nor.png */; }; + A9B965C41A6D35820017F9F2 /* chat_bottom_smile_press.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B21A6D35820017F9F2 /* chat_bottom_smile_press.png */; }; + A9B965C51A6D35820017F9F2 /* chat_bottom_textfield.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B31A6D35820017F9F2 /* chat_bottom_textfield.png */; }; + A9B965C61A6D35820017F9F2 /* chat_bottom_up_nor.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B41A6D35820017F9F2 /* chat_bottom_up_nor.png */; }; + A9B965C71A6D35820017F9F2 /* chat_bottom_up_press.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B51A6D35820017F9F2 /* chat_bottom_up_press.png */; }; + A9B965C81A6D35820017F9F2 /* chat_bottom_voice_nor.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B61A6D35820017F9F2 /* chat_bottom_voice_nor.png */; }; + A9B965C91A6D35820017F9F2 /* chat_bottom_voice_press.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B71A6D35820017F9F2 /* chat_bottom_voice_press.png */; }; + A9B965CA1A6D35820017F9F2 /* chatfrom_bg_focused.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B81A6D35820017F9F2 /* chatfrom_bg_focused.png */; }; + A9B965CB1A6D35820017F9F2 /* chatfrom_bg_normal.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965B91A6D35820017F9F2 /* chatfrom_bg_normal.png */; }; + A9B965CC1A6D35820017F9F2 /* chatto_bg_focused.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965BA1A6D35820017F9F2 /* chatto_bg_focused.png */; }; + A9B965CD1A6D35820017F9F2 /* chatto_bg_normal.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965BB1A6D35820017F9F2 /* chatto_bg_normal.png */; }; + A9B965CE1A6D35820017F9F2 /* icon01.jpg in Resources */ = {isa = PBXBuildFile; fileRef = A9B965BC1A6D35820017F9F2 /* icon01.jpg */; }; + A9B965CF1A6D35820017F9F2 /* icon02.jpg in Resources */ = {isa = PBXBuildFile; fileRef = A9B965BD1A6D35820017F9F2 /* icon02.jpg */; }; + A9B965D01A6D35820017F9F2 /* toolbar_bottom_bar.png in Resources */ = {isa = PBXBuildFile; fileRef = A9B965BE1A6D35820017F9F2 /* toolbar_bottom_bar.png */; }; + A9B965D11A6D35820017F9F2 /* messages.plist in Resources */ = {isa = PBXBuildFile; fileRef = A9B965BF1A6D35820017F9F2 /* messages.plist */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -43,6 +68,39 @@ A97429C61A68C81C00732735 /* ASHMessageTableViewDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASHMessageTableViewDemoTests.m; sourceTree = ""; }; A9B965531A6D307B0017F9F2 /* MessageTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageTableView.h; sourceTree = ""; }; A9B965541A6D307B0017F9F2 /* MessageTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageTableView.m; sourceTree = ""; }; + A9B965951A6D35300017F9F2 /* NSString+DocumentPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+DocumentPath.h"; sourceTree = ""; }; + A9B965961A6D35300017F9F2 /* NSString+DocumentPath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+DocumentPath.m"; sourceTree = ""; }; + A9B965971A6D35300017F9F2 /* UIImage+StrethImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+StrethImage.h"; sourceTree = ""; }; + A9B965981A6D35300017F9F2 /* UIImage+StrethImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+StrethImage.m"; sourceTree = ""; }; + A9B9659A1A6D35300017F9F2 /* ChartCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartCell.h; sourceTree = ""; }; + A9B9659B1A6D35300017F9F2 /* ChartCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChartCell.m; sourceTree = ""; }; + A9B9659C1A6D35300017F9F2 /* ChartCellFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartCellFrame.h; sourceTree = ""; }; + A9B9659D1A6D35300017F9F2 /* ChartCellFrame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChartCellFrame.m; sourceTree = ""; }; + A9B9659F1A6D35300017F9F2 /* ChartMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartMessage.h; sourceTree = ""; }; + A9B965A01A6D35300017F9F2 /* ChartMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChartMessage.m; sourceTree = ""; }; + A9B965A21A6D35300017F9F2 /* ChartContentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChartContentView.h; sourceTree = ""; }; + A9B965A31A6D35300017F9F2 /* ChartContentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChartContentView.m; sourceTree = ""; }; + A9B965A41A6D35300017F9F2 /* KeyBordVIew.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyBordVIew.h; sourceTree = ""; }; + A9B965A51A6D35300017F9F2 /* KeyBordVIew.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KeyBordVIew.m; sourceTree = ""; }; + A9B965AE1A6D35820017F9F2 /* chat_bg_default.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = chat_bg_default.jpg; sourceTree = ""; }; + A9B965AF1A6D35820017F9F2 /* chat_bottom_keyboard_nor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chat_bottom_keyboard_nor.png; sourceTree = ""; }; + A9B965B01A6D35820017F9F2 /* chat_bottom_keyboard_press.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chat_bottom_keyboard_press.png; sourceTree = ""; }; + A9B965B11A6D35820017F9F2 /* chat_bottom_smile_nor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chat_bottom_smile_nor.png; sourceTree = ""; }; + A9B965B21A6D35820017F9F2 /* chat_bottom_smile_press.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chat_bottom_smile_press.png; sourceTree = ""; }; + A9B965B31A6D35820017F9F2 /* chat_bottom_textfield.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chat_bottom_textfield.png; sourceTree = ""; }; + A9B965B41A6D35820017F9F2 /* chat_bottom_up_nor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chat_bottom_up_nor.png; sourceTree = ""; }; + A9B965B51A6D35820017F9F2 /* chat_bottom_up_press.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chat_bottom_up_press.png; sourceTree = ""; }; + A9B965B61A6D35820017F9F2 /* chat_bottom_voice_nor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chat_bottom_voice_nor.png; sourceTree = ""; }; + A9B965B71A6D35820017F9F2 /* chat_bottom_voice_press.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chat_bottom_voice_press.png; sourceTree = ""; }; + A9B965B81A6D35820017F9F2 /* chatfrom_bg_focused.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chatfrom_bg_focused.png; sourceTree = ""; }; + A9B965B91A6D35820017F9F2 /* chatfrom_bg_normal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chatfrom_bg_normal.png; sourceTree = ""; }; + A9B965BA1A6D35820017F9F2 /* chatto_bg_focused.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chatto_bg_focused.png; sourceTree = ""; }; + A9B965BB1A6D35820017F9F2 /* chatto_bg_normal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = chatto_bg_normal.png; sourceTree = ""; }; + A9B965BC1A6D35820017F9F2 /* icon01.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = icon01.jpg; sourceTree = ""; }; + A9B965BD1A6D35820017F9F2 /* icon02.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = icon02.jpg; sourceTree = ""; }; + A9B965BE1A6D35820017F9F2 /* toolbar_bottom_bar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = toolbar_bottom_bar.png; sourceTree = ""; }; + A9B965BF1A6D35820017F9F2 /* messages.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = messages.plist; sourceTree = ""; }; + A9B965D21A6D358B0017F9F2 /* ASHMessageTableViewDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ASHMessageTableViewDemo-Prefix.pch"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -84,6 +142,10 @@ A97429A91A68C81C00732735 /* ASHMessageTableViewDemo */ = { isa = PBXGroup; children = ( + A9B965941A6D35300017F9F2 /* category */, + A9B965991A6D35300017F9F2 /* cell */, + A9B9659E1A6D35300017F9F2 /* model */, + A9B965A11A6D35300017F9F2 /* view */, A97429AE1A68C81C00732735 /* AppDelegate.h */, A97429AF1A68C81C00732735 /* AppDelegate.m */, A97429B11A68C81C00732735 /* ViewController.h */, @@ -101,6 +163,9 @@ A97429AA1A68C81C00732735 /* Supporting Files */ = { isa = PBXGroup; children = ( + A9B965D21A6D358B0017F9F2 /* ASHMessageTableViewDemo-Prefix.pch */, + A9B965AD1A6D35820017F9F2 /* images */, + A9B965BF1A6D35820017F9F2 /* messages.plist */, A97429AB1A68C81C00732735 /* Info.plist */, A97429AC1A68C81C00732735 /* main.m */, ); @@ -124,6 +189,72 @@ name = "Supporting Files"; sourceTree = ""; }; + A9B965941A6D35300017F9F2 /* category */ = { + isa = PBXGroup; + children = ( + A9B965951A6D35300017F9F2 /* NSString+DocumentPath.h */, + A9B965961A6D35300017F9F2 /* NSString+DocumentPath.m */, + A9B965971A6D35300017F9F2 /* UIImage+StrethImage.h */, + A9B965981A6D35300017F9F2 /* UIImage+StrethImage.m */, + ); + path = category; + sourceTree = ""; + }; + A9B965991A6D35300017F9F2 /* cell */ = { + isa = PBXGroup; + children = ( + A9B9659A1A6D35300017F9F2 /* ChartCell.h */, + A9B9659B1A6D35300017F9F2 /* ChartCell.m */, + A9B9659C1A6D35300017F9F2 /* ChartCellFrame.h */, + A9B9659D1A6D35300017F9F2 /* ChartCellFrame.m */, + ); + path = cell; + sourceTree = ""; + }; + A9B9659E1A6D35300017F9F2 /* model */ = { + isa = PBXGroup; + children = ( + A9B9659F1A6D35300017F9F2 /* ChartMessage.h */, + A9B965A01A6D35300017F9F2 /* ChartMessage.m */, + ); + path = model; + sourceTree = ""; + }; + A9B965A11A6D35300017F9F2 /* view */ = { + isa = PBXGroup; + children = ( + A9B965A21A6D35300017F9F2 /* ChartContentView.h */, + A9B965A31A6D35300017F9F2 /* ChartContentView.m */, + A9B965A41A6D35300017F9F2 /* KeyBordVIew.h */, + A9B965A51A6D35300017F9F2 /* KeyBordVIew.m */, + ); + path = view; + sourceTree = ""; + }; + A9B965AD1A6D35820017F9F2 /* images */ = { + isa = PBXGroup; + children = ( + A9B965AE1A6D35820017F9F2 /* chat_bg_default.jpg */, + A9B965AF1A6D35820017F9F2 /* chat_bottom_keyboard_nor.png */, + A9B965B01A6D35820017F9F2 /* chat_bottom_keyboard_press.png */, + A9B965B11A6D35820017F9F2 /* chat_bottom_smile_nor.png */, + A9B965B21A6D35820017F9F2 /* chat_bottom_smile_press.png */, + A9B965B31A6D35820017F9F2 /* chat_bottom_textfield.png */, + A9B965B41A6D35820017F9F2 /* chat_bottom_up_nor.png */, + A9B965B51A6D35820017F9F2 /* chat_bottom_up_press.png */, + A9B965B61A6D35820017F9F2 /* chat_bottom_voice_nor.png */, + A9B965B71A6D35820017F9F2 /* chat_bottom_voice_press.png */, + A9B965B81A6D35820017F9F2 /* chatfrom_bg_focused.png */, + A9B965B91A6D35820017F9F2 /* chatfrom_bg_normal.png */, + A9B965BA1A6D35820017F9F2 /* chatto_bg_focused.png */, + A9B965BB1A6D35820017F9F2 /* chatto_bg_normal.png */, + A9B965BC1A6D35820017F9F2 /* icon01.jpg */, + A9B965BD1A6D35820017F9F2 /* icon02.jpg */, + A9B965BE1A6D35820017F9F2 /* toolbar_bottom_bar.png */, + ); + path = images; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -206,7 +337,25 @@ files = ( A97429B61A68C81C00732735 /* Main.storyboard in Resources */, A97429BB1A68C81C00732735 /* LaunchScreen.xib in Resources */, + A9B965CF1A6D35820017F9F2 /* icon02.jpg in Resources */, + A9B965CB1A6D35820017F9F2 /* chatfrom_bg_normal.png in Resources */, + A9B965D01A6D35820017F9F2 /* toolbar_bottom_bar.png in Resources */, + A9B965C51A6D35820017F9F2 /* chat_bottom_textfield.png in Resources */, + A9B965C81A6D35820017F9F2 /* chat_bottom_voice_nor.png in Resources */, + A9B965CA1A6D35820017F9F2 /* chatfrom_bg_focused.png in Resources */, + A9B965C61A6D35820017F9F2 /* chat_bottom_up_nor.png in Resources */, + A9B965C01A6D35820017F9F2 /* chat_bg_default.jpg in Resources */, + A9B965C21A6D35820017F9F2 /* chat_bottom_keyboard_press.png in Resources */, + A9B965D11A6D35820017F9F2 /* messages.plist in Resources */, A97429B81A68C81C00732735 /* Images.xcassets in Resources */, + A9B965C91A6D35820017F9F2 /* chat_bottom_voice_press.png in Resources */, + A9B965CD1A6D35820017F9F2 /* chatto_bg_normal.png in Resources */, + A9B965CC1A6D35820017F9F2 /* chatto_bg_focused.png in Resources */, + A9B965CE1A6D35820017F9F2 /* icon01.jpg in Resources */, + A9B965C31A6D35820017F9F2 /* chat_bottom_smile_nor.png in Resources */, + A9B965C11A6D35820017F9F2 /* chat_bottom_keyboard_nor.png in Resources */, + A9B965C71A6D35820017F9F2 /* chat_bottom_up_press.png in Resources */, + A9B965C41A6D35820017F9F2 /* chat_bottom_smile_press.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -224,10 +373,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + A9B965A91A6D35300017F9F2 /* ChartCellFrame.m in Sources */, + A9B965A61A6D35300017F9F2 /* NSString+DocumentPath.m in Sources */, + A9B965AC1A6D35300017F9F2 /* KeyBordVIew.m in Sources */, A97429B31A68C81C00732735 /* ViewController.m in Sources */, A9B965551A6D307B0017F9F2 /* MessageTableView.m in Sources */, A97429B01A68C81C00732735 /* AppDelegate.m in Sources */, + A9B965A81A6D35300017F9F2 /* ChartCell.m in Sources */, + A9B965AA1A6D35300017F9F2 /* ChartMessage.m in Sources */, + A9B965AB1A6D35300017F9F2 /* ChartContentView.m in Sources */, A97429AD1A68C81C00732735 /* main.m in Sources */, + A9B965A71A6D35300017F9F2 /* UIImage+StrethImage.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -349,6 +505,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + GCC_PREFIX_HEADER = "ASHMessageTableViewDemo/ASHMessageTableViewDemo-Prefix.pch"; INFOPLIST_FILE = ASHMessageTableViewDemo/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -359,6 +516,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + GCC_PREFIX_HEADER = "ASHMessageTableViewDemo/ASHMessageTableViewDemo-Prefix.pch"; INFOPLIST_FILE = ASHMessageTableViewDemo/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/ASHMessageTableViewDemo.xcodeproj/project.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate b/ASHMessageTableViewDemo.xcodeproj/project.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate index 9d7aada..7fbcc3e 100644 Binary files a/ASHMessageTableViewDemo.xcodeproj/project.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate and b/ASHMessageTableViewDemo.xcodeproj/project.xcworkspace/xcuserdata/xmfish.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ASHMessageTableViewDemo/ASHMessageTableViewDemo-Prefix.pch b/ASHMessageTableViewDemo/ASHMessageTableViewDemo-Prefix.pch new file mode 100644 index 0000000..5757274 --- /dev/null +++ b/ASHMessageTableViewDemo/ASHMessageTableViewDemo-Prefix.pch @@ -0,0 +1,18 @@ +// +// Prefix header +// +// The contents of this file are implicitly included at the beginning of every source file. +// + +#import + +#ifndef __IPHONE_5_0 +#warning "This project uses features only available in iOS SDK 5.0 and later." +#endif + +#ifdef __OBJC__ + #import + #import +#import "UIImage+StrethImage.h" +#import "NSString+DocumentPath.h" +#endif diff --git a/ASHMessageTableViewDemo/AppDelegate.m b/ASHMessageTableViewDemo/AppDelegate.m index 859c8b4..777398a 100644 --- a/ASHMessageTableViewDemo/AppDelegate.m +++ b/ASHMessageTableViewDemo/AppDelegate.m @@ -7,7 +7,7 @@ // #import "AppDelegate.h" - +#import "ViewController.h" @interface AppDelegate () @end @@ -17,6 +17,10 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. + self.window=[[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; + UINavigationController *nav=[[[UINavigationController alloc]initWithRootViewController:[ViewController alloc]]init]; + self.window.rootViewController=nav; + [self.window makeKeyAndVisible]; return YES; } diff --git a/ASHMessageTableViewDemo/ViewController.m b/ASHMessageTableViewDemo/ViewController.m index e57815e..fffdf85 100644 --- a/ASHMessageTableViewDemo/ViewController.m +++ b/ASHMessageTableViewDemo/ViewController.m @@ -7,21 +7,309 @@ // #import "ViewController.h" - -@interface ViewController () - +#import "ChartMessage.h" +#import "ChartCellFrame.h" +#import "ChartCell.h" +#import "KeyBordVIew.h" +#import +#import +#import "MessageTableView.h" +@interface ViewController () +@property (nonatomic,strong) MessageTableView *tableView; +@property (nonatomic,strong) KeyBordVIew *keyBordView; +@property (nonatomic,strong) NSMutableArray *cellFrames; +@property (nonatomic,assign) BOOL recording; +@property (nonatomic,strong) NSString *fileName; +@property (nonatomic,strong) AVAudioRecorder *recorder; +@property (nonatomic,strong) AVAudioPlayer *player; @end - +static NSString *const cellIdentifier=@"QQChart"; @implementation ViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. +{ + UIActivityIndicatorView* _activity; + BOOL _isRefresh; + UIView* _headView; +} +-(void)viewWillAppear:(BOOL)animated +{ + [super viewWillAppear:animated]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardShow:) name:UIKeyboardWillShowNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardHide:) name:UIKeyboardWillHideNotification object:nil]; } -- (void)didReceiveMemoryWarning { +-(void)keyboardShow:(NSNotification *)note +{ + CGRect keyBoardRect=[note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue]; + CGFloat deltaY=keyBoardRect.size.height; + + [UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue] animations:^{ + + self.view.transform=CGAffineTransformMakeTranslation(0, -deltaY); + }]; +} +-(void)keyboardHide:(NSNotification *)note +{ + [UIView animateWithDuration:[note.userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue] animations:^{ + self.view.transform = CGAffineTransformIdentity; + }]; +} +- (void)viewDidLoad +{ + [super viewDidLoad]; + + self.title=@"QQ chat"; + self.view.backgroundColor=[UIColor whiteColor]; + + //add UItableView + self.tableView=[[MessageTableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-108) style:UITableViewStylePlain]; + [self.tableView registerClass:[ChartCell class] forCellReuseIdentifier:cellIdentifier]; + self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone; + self.tableView.allowsSelection = NO; + self.tableView.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chat_bg_default.jpg"]]; + self.tableView.dataSource=self; + self.tableView.delegate=self; + [self.view addSubview:self.tableView]; + + //add keyBorad + + self.keyBordView=[[KeyBordVIew alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height-108, self.view.frame.size.width, 44)]; + self.keyBordView.delegate=self; + [self.view addSubview:self.keyBordView]; + //初始化数据 + + // [self.tableView addHeaderWithTarget:self action:@selector(headerRereshing)]; + // [self.tableView addFooterWithTarget:self action:@selector(footerRereshing)]; + + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(testTableView)]; + [self initwithData]; + + _headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)]; + _headView.backgroundColor = [UIColor clearColor]; + + _activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; + [_headView addSubview:_activity]; + _activity.frame = CGRectMake(_headView.frame.size.width/2, _headView.frame.size.height/2, 20, 20); + + _tableView.tableHeaderView = _headView; + _headView.hidden = YES; +} +-(void)testTableView +{ + //等待2s + _headView.hidden = NO; + [_activity startAnimating]; + _isRefresh = YES; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + NSString *path=[[NSBundle mainBundle] pathForResource:@"messages" ofType:@"plist"]; + NSArray *data=[NSArray arrayWithContentsOfFile:path]; + + int i = 0; + for(NSDictionary *dict in data){ + if (i>=5) { + break; + } + i++; + ChartCellFrame *cellFrame=[[ChartCellFrame alloc]init]; + ChartMessage *chartMessage=[[ChartMessage alloc]init]; + chartMessage.dict=dict; + cellFrame.chartMessage=chartMessage; + [self.cellFrames insertObject:cellFrame atIndex:0]; + } + + [_tableView reloadData]; + [_activity stopAnimating]; + _headView.hidden = YES; + _isRefresh = NO; + }); + + + + + +} + +-(void)initwithData +{ + self.cellFrames=[NSMutableArray array]; + + NSString *path=[[NSBundle mainBundle] pathForResource:@"messages" ofType:@"plist"]; + NSArray *data=[NSArray arrayWithContentsOfFile:path]; + + for(NSDictionary *dict in data){ + + ChartCellFrame *cellFrame=[[ChartCellFrame alloc]init]; + ChartMessage *chartMessage=[[ChartMessage alloc]init]; + chartMessage.dict=dict; + cellFrame.chartMessage=chartMessage; + [self.cellFrames addObject:cellFrame]; + } + + + +} + +-(void)scrollViewDidScroll:(UIScrollView *)scrollView +{ + if (scrollView.contentOffset.y<=0 && _isRefresh==NO) + { + [self testTableView]; + } +} +-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +{ + NSLog(@"%ld",_cellFrames.count); + return _cellFrames.count; +} +-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +{ + return 1; +} +-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +{ + ChartCell *cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; + cell.delegate=self; + cell.cellFrame=self.cellFrames[indexPath.row]; + return cell; + +} +-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + return [self.cellFrames[indexPath.row] cellHeight]; +} +-(void)chartCell:(ChartCell *)chartCell tapContent:(NSString *)content +{ + if(self.player.isPlaying){ + + [self.player stop]; + } + //播放 + NSString *filePath=[NSString documentPathWith:content]; + NSURL *fileUrl=[NSURL fileURLWithPath:filePath]; + [self initPlayer]; + NSError *error; + self.player=[[AVAudioPlayer alloc]initWithContentsOfURL:fileUrl error:&error]; + [self.player setVolume:1]; + [self.player prepareToPlay]; + [self.player setDelegate:self]; + [self.player play]; + [[UIDevice currentDevice] setProximityMonitoringEnabled:YES]; +} +-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag +{ + [[UIDevice currentDevice]setProximityMonitoringEnabled:NO]; + [self.player stop]; + self.player=nil; +} +-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView +{ + + [self.view endEditing:YES]; +} +-(void)KeyBordView:(KeyBordVIew *)keyBoardView textFiledReturn:(UITextField *)textFiled +{ + ChartCellFrame *cellFrame=[[ChartCellFrame alloc]init]; + ChartMessage *chartMessage=[[ChartMessage alloc]init]; + + int random=arc4random_uniform(2); + NSLog(@"%d",random); + chartMessage.icon=[NSString stringWithFormat:@"icon%02d.jpg",random+1]; + chartMessage.messageType=random; + chartMessage.content=textFiled.text; + cellFrame.chartMessage=chartMessage; + + [self.cellFrames addObject:cellFrame]; + [self.tableView reloadData]; + + //滚动到当前行 + + [self tableViewScrollCurrentIndexPath]; + textFiled.text=@""; + +} +-(void)KeyBordView:(KeyBordVIew *)keyBoardView textFiledBegin:(UITextField *)textFiled +{ + [self tableViewScrollCurrentIndexPath]; + +} +-(void)beginRecord +{ + if(self.recording)return; + + self.recording=YES; + + NSDictionary *settings=[NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithFloat:8000],AVSampleRateKey, + [NSNumber numberWithInt:kAudioFormatLinearPCM],AVFormatIDKey, + [NSNumber numberWithInt:1],AVNumberOfChannelsKey, + [NSNumber numberWithInt:16],AVLinearPCMBitDepthKey, + [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey, + [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey, + nil]; + [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error: nil]; + [[AVAudioSession sharedInstance] setActive:YES error:nil]; + NSDate *now = [NSDate date]; + NSDateFormatter *dateFormater = [[NSDateFormatter alloc] init]; + [dateFormater setDateFormat:@"yyyyMMddHHmmss"]; + NSString *fileName = [NSString stringWithFormat:@"rec_%@.wav",[dateFormater stringFromDate:now]]; + self.fileName=fileName; + NSString *filePath=[NSString documentPathWith:fileName]; + NSURL *fileUrl=[NSURL fileURLWithPath:filePath]; + NSError *error; + self.recorder=[[AVAudioRecorder alloc]initWithURL:fileUrl settings:settings error:&error]; + [self.recorder prepareToRecord]; + [self.recorder setMeteringEnabled:YES]; + [self.recorder peakPowerForChannel:0]; + [self.recorder record]; + +} +-(void)finishRecord +{ + self.recording=NO; + [self.recorder stop]; + self.recorder=nil; + ChartCellFrame *cellFrame=[[ChartCellFrame alloc]init]; + ChartMessage *chartMessage=[[ChartMessage alloc]init]; + + int random=arc4random_uniform(2); + NSLog(@"%d",random); + chartMessage.icon=[NSString stringWithFormat:@"icon%02d.jpg",random+1]; + chartMessage.messageType=random; + chartMessage.content=self.fileName; + cellFrame.chartMessage=chartMessage; + [self.cellFrames addObject:cellFrame]; + [self.tableView reloadData]; + [self tableViewScrollCurrentIndexPath]; + +} +-(void)tableViewScrollCurrentIndexPath +{ + NSIndexPath *indexPath=[NSIndexPath indexPathForRow:self.cellFrames.count-1 inSection:0]; + [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; +} +-(void)initPlayer{ + //初始化播放器的时候如下设置 + UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback; + AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, + sizeof(sessionCategory), + &sessionCategory); + + UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; + AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, + sizeof (audioRouteOverride), + &audioRouteOverride); + + AVAudioSession *audioSession = [AVAudioSession sharedInstance]; + //默认情况下扬声器播放 + [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil]; + [audioSession setActive:YES error:nil]; + audioSession = nil; +} +- (void)didReceiveMemoryWarning +{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end + diff --git a/ASHMessageTableViewDemo/category/NSString+DocumentPath.h b/ASHMessageTableViewDemo/category/NSString+DocumentPath.h new file mode 100644 index 0000000..ac4ba02 --- /dev/null +++ b/ASHMessageTableViewDemo/category/NSString+DocumentPath.h @@ -0,0 +1,13 @@ +// +// NSString+DocumentPath.h +// 气泡 +// +// Created by zzy on 14-5-15. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import + +@interface NSString (DocumentPath) ++(NSString *)documentPathWith:(NSString *)fileName; +@end diff --git a/ASHMessageTableViewDemo/category/NSString+DocumentPath.m b/ASHMessageTableViewDemo/category/NSString+DocumentPath.m new file mode 100644 index 0000000..a4f3d86 --- /dev/null +++ b/ASHMessageTableViewDemo/category/NSString+DocumentPath.m @@ -0,0 +1,17 @@ +// +// NSString+DocumentPath.m +// 气泡 +// +// Created by zzy on 14-5-15. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import "NSString+DocumentPath.h" + +@implementation NSString (DocumentPath) ++(NSString *)documentPathWith:(NSString *)fileName +{ + + return [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",fileName]]; +} +@end diff --git a/ASHMessageTableViewDemo/category/UIImage+StrethImage.h b/ASHMessageTableViewDemo/category/UIImage+StrethImage.h new file mode 100644 index 0000000..568d748 --- /dev/null +++ b/ASHMessageTableViewDemo/category/UIImage+StrethImage.h @@ -0,0 +1,14 @@ +// +// UIImage+StrethImage.h +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import + +@interface UIImage (StrethImage) + ++(id)strethImageWith:(NSString *)imageName; +@end diff --git a/ASHMessageTableViewDemo/category/UIImage+StrethImage.m b/ASHMessageTableViewDemo/category/UIImage+StrethImage.m new file mode 100644 index 0000000..ca90bc7 --- /dev/null +++ b/ASHMessageTableViewDemo/category/UIImage+StrethImage.m @@ -0,0 +1,21 @@ +// +// UIImage+StrethImage.m +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import "UIImage+StrethImage.h" + +@implementation UIImage (StrethImage) + ++(id)strethImageWith:(NSString *)imageName +{ + UIImage *image=[UIImage imageNamed:imageName]; + + image=[image stretchableImageWithLeftCapWidth:image.size.width*0.5 topCapHeight:image.size.height*0.5]; + + return image; +} +@end diff --git a/ASHMessageTableViewDemo/cell/.DS_Store b/ASHMessageTableViewDemo/cell/.DS_Store new file mode 100644 index 0000000..f3b4fde Binary files /dev/null and b/ASHMessageTableViewDemo/cell/.DS_Store differ diff --git a/ASHMessageTableViewDemo/cell/ChartCell.h b/ASHMessageTableViewDemo/cell/ChartCell.h new file mode 100644 index 0000000..534e6ad --- /dev/null +++ b/ASHMessageTableViewDemo/cell/ChartCell.h @@ -0,0 +1,22 @@ +// +// ChartCell.h +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import +@class ChartCell; + +@protocol ChartCellDelegate + +-(void)chartCell:(ChartCell *)chartCell tapContent:(NSString *)content; + +@end + +#import "ChartCellFrame.h" +@interface ChartCell : UITableViewCell +@property (nonatomic,strong) ChartCellFrame *cellFrame; +@property (nonatomic,assign) id delegate; +@end diff --git a/ASHMessageTableViewDemo/cell/ChartCell.m b/ASHMessageTableViewDemo/cell/ChartCell.m new file mode 100644 index 0000000..4c8cdbd --- /dev/null +++ b/ASHMessageTableViewDemo/cell/ChartCell.m @@ -0,0 +1,117 @@ +// +// ChartCell.m +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import "ChartCell.h" +#import "ChartContentView.h" +@interface ChartCell() +@property (nonatomic,strong) UIImageView *icon; +@property (nonatomic,strong) ChartContentView *chartView; +@property (nonatomic,strong) ChartContentView *currentChartView; +@property (nonatomic,strong) NSString *contentStr; +@end + +@implementation ChartCell + +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + self.backgroundColor = [UIColor clearColor]; + self.icon=[[UIImageView alloc]init]; + [self.contentView addSubview:self.icon]; + self.chartView =[[ChartContentView alloc]initWithFrame:CGRectZero]; + self.chartView.delegate=self; + [self.contentView addSubview:self.chartView]; + } + return self; +} +-(void)setCellFrame:(ChartCellFrame *)cellFrame +{ + + _cellFrame=cellFrame; + + ChartMessage *chartMessage=cellFrame.chartMessage; + + self.icon.frame=cellFrame.iconRect; + self.icon.image=[UIImage imageNamed:chartMessage.icon]; + + self.chartView.chartMessage=chartMessage; + self.chartView.frame=cellFrame.chartViewRect; + [self setBackGroundImageViewImage:self.chartView from:@"chatfrom_bg_normal.png" to:@"chatto_bg_normal.png"]; + self.chartView.contentLabel.text=chartMessage.content; + +} +-(void)setBackGroundImageViewImage:(ChartContentView *)chartView from:(NSString *)from to:(NSString *)to +{ + UIImage *normal=nil ; + if(chartView.chartMessage.messageType==kMessageFrom){ + + normal = [UIImage imageNamed:from]; + normal = [normal stretchableImageWithLeftCapWidth:normal.size.width * 0.5 topCapHeight:normal.size.height * 0.7]; + + }else if(chartView.chartMessage.messageType==kMessageTo){ + + normal = [UIImage imageNamed:to]; + normal = [normal stretchableImageWithLeftCapWidth:normal.size.width * 0.5 topCapHeight:normal.size.height * 0.7]; + } + chartView.backImageView.image=normal; +} +-(void)chartContentViewLongPress:(ChartContentView *)chartView content:(NSString *)content +{ + [self becomeFirstResponder]; + UIMenuController *menu=[UIMenuController sharedMenuController]; + [menu setTargetRect:self.bounds inView:self]; + [menu setMenuVisible:YES animated:YES]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuShow:) name:UIMenuControllerWillShowMenuNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuHide:) name:UIMenuControllerWillHideMenuNotification object:nil]; + self.contentStr=content; + self.currentChartView=chartView; +} +-(void)chartContentViewTapPress:(ChartContentView *)chartView content:(NSString *)content +{ + if([self.delegate respondsToSelector:@selector(chartCell:tapContent:)]){ + + + [self.delegate chartCell:self tapContent:content]; + } +} +-(void)menuShow:(UIMenuController *)menu +{ + [self setBackGroundImageViewImage:self.currentChartView from:@"chatfrom_bg_focused.png" to:@"chatto_bg_focused.png"]; +} +-(void)menuHide:(UIMenuController *)menu +{ + [self setBackGroundImageViewImage:self.currentChartView from:@"chatfrom_bg_normal.png" to:@"chatto_bg_normal.png"]; + self.currentChartView=nil; + [self resignFirstResponder]; +} +-(BOOL)canPerformAction:(SEL)action withSender:(id)sender +{ + if(action ==@selector(copy:)){ + + return YES; + } + return [super canPerformAction:action withSender:sender]; +} + +-(void)copy:(id)sender +{ + [[UIPasteboard generalPasteboard]setString:self.contentStr]; +} +-(BOOL)canBecomeFirstResponder +{ + return YES; +} +- (void)setSelected:(BOOL)selected animated:(BOOL)animated +{ + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/ASHMessageTableViewDemo/cell/ChartCellFrame.h b/ASHMessageTableViewDemo/cell/ChartCellFrame.h new file mode 100644 index 0000000..81cf869 --- /dev/null +++ b/ASHMessageTableViewDemo/cell/ChartCellFrame.h @@ -0,0 +1,16 @@ +// +// ChartCellFrame.h +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import +#import "ChartMessage.h" +@interface ChartCellFrame : NSObject +@property (nonatomic,assign) CGRect iconRect; +@property (nonatomic,assign) CGRect chartViewRect; +@property (nonatomic,strong) ChartMessage *chartMessage; +@property (nonatomic, assign) CGFloat cellHeight; //cell高度 +@end diff --git a/ASHMessageTableViewDemo/cell/ChartCellFrame.m b/ASHMessageTableViewDemo/cell/ChartCellFrame.m new file mode 100644 index 0000000..83bd372 --- /dev/null +++ b/ASHMessageTableViewDemo/cell/ChartCellFrame.m @@ -0,0 +1,45 @@ +// +// ChartCellFrame.m +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// +#define kIconMarginX 5 +#define kIconMarginY 5 + +#import "ChartCellFrame.h" + +@implementation ChartCellFrame + +-(void)setChartMessage:(ChartMessage *)chartMessage +{ + _chartMessage=chartMessage; + + CGSize winSize=[UIScreen mainScreen].bounds.size; + CGFloat iconX=kIconMarginX; + CGFloat iconY=kIconMarginY; + CGFloat iconWidth=40; + CGFloat iconHeight=40; + + if(chartMessage.messageType==kMessageFrom){ + + }else if (chartMessage.messageType==kMessageTo){ + iconX=winSize.width-kIconMarginX-iconWidth; + } + self.iconRect=CGRectMake(iconX, iconY, iconWidth, iconHeight); + + CGFloat contentX=CGRectGetMaxX(self.iconRect)+kIconMarginX; + CGFloat contentY=iconY; + NSDictionary *attributes = @{NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue" size:13]}; + CGSize contentSize=[chartMessage.content boundingRectWithSize:CGSizeMake(200, MAXFLOAT) options: NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:attributes context:nil].size; + if(chartMessage.messageType==kMessageTo){ + + contentX=iconX-kIconMarginX-contentSize.width-iconWidth; + } + + self.chartViewRect=CGRectMake(contentX, contentY, contentSize.width+35, contentSize.height+30); + + self.cellHeight=MAX(CGRectGetMaxY(self.iconRect), CGRectGetMaxY(self.chartViewRect))+kIconMarginX; +} +@end diff --git a/ASHMessageTableViewDemo/images/chat_bg_default.jpg b/ASHMessageTableViewDemo/images/chat_bg_default.jpg new file mode 100644 index 0000000..7b1675a Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bg_default.jpg differ diff --git a/ASHMessageTableViewDemo/images/chat_bottom_keyboard_nor.png b/ASHMessageTableViewDemo/images/chat_bottom_keyboard_nor.png new file mode 100755 index 0000000..83e65b7 Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bottom_keyboard_nor.png differ diff --git a/ASHMessageTableViewDemo/images/chat_bottom_keyboard_press.png b/ASHMessageTableViewDemo/images/chat_bottom_keyboard_press.png new file mode 100755 index 0000000..9b6550a Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bottom_keyboard_press.png differ diff --git a/ASHMessageTableViewDemo/images/chat_bottom_smile_nor.png b/ASHMessageTableViewDemo/images/chat_bottom_smile_nor.png new file mode 100755 index 0000000..f089d60 Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bottom_smile_nor.png differ diff --git a/ASHMessageTableViewDemo/images/chat_bottom_smile_press.png b/ASHMessageTableViewDemo/images/chat_bottom_smile_press.png new file mode 100755 index 0000000..429b7e7 Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bottom_smile_press.png differ diff --git a/ASHMessageTableViewDemo/images/chat_bottom_textfield.png b/ASHMessageTableViewDemo/images/chat_bottom_textfield.png new file mode 100755 index 0000000..9f60d02 Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bottom_textfield.png differ diff --git a/ASHMessageTableViewDemo/images/chat_bottom_up_nor.png b/ASHMessageTableViewDemo/images/chat_bottom_up_nor.png new file mode 100755 index 0000000..c535e4c Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bottom_up_nor.png differ diff --git a/ASHMessageTableViewDemo/images/chat_bottom_up_press.png b/ASHMessageTableViewDemo/images/chat_bottom_up_press.png new file mode 100755 index 0000000..c4edeeb Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bottom_up_press.png differ diff --git a/ASHMessageTableViewDemo/images/chat_bottom_voice_nor.png b/ASHMessageTableViewDemo/images/chat_bottom_voice_nor.png new file mode 100755 index 0000000..9da22d0 Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bottom_voice_nor.png differ diff --git a/ASHMessageTableViewDemo/images/chat_bottom_voice_press.png b/ASHMessageTableViewDemo/images/chat_bottom_voice_press.png new file mode 100755 index 0000000..ba38c1d Binary files /dev/null and b/ASHMessageTableViewDemo/images/chat_bottom_voice_press.png differ diff --git a/ASHMessageTableViewDemo/images/chatfrom_bg_focused.png b/ASHMessageTableViewDemo/images/chatfrom_bg_focused.png new file mode 100644 index 0000000..0d83745 Binary files /dev/null and b/ASHMessageTableViewDemo/images/chatfrom_bg_focused.png differ diff --git a/ASHMessageTableViewDemo/images/chatfrom_bg_normal.png b/ASHMessageTableViewDemo/images/chatfrom_bg_normal.png new file mode 100644 index 0000000..efb7ede Binary files /dev/null and b/ASHMessageTableViewDemo/images/chatfrom_bg_normal.png differ diff --git a/ASHMessageTableViewDemo/images/chatto_bg_focused.png b/ASHMessageTableViewDemo/images/chatto_bg_focused.png new file mode 100644 index 0000000..8587f63 Binary files /dev/null and b/ASHMessageTableViewDemo/images/chatto_bg_focused.png differ diff --git a/ASHMessageTableViewDemo/images/chatto_bg_normal.png b/ASHMessageTableViewDemo/images/chatto_bg_normal.png new file mode 100644 index 0000000..86893f5 Binary files /dev/null and b/ASHMessageTableViewDemo/images/chatto_bg_normal.png differ diff --git a/ASHMessageTableViewDemo/images/icon01.jpg b/ASHMessageTableViewDemo/images/icon01.jpg new file mode 100644 index 0000000..7b42040 Binary files /dev/null and b/ASHMessageTableViewDemo/images/icon01.jpg differ diff --git a/ASHMessageTableViewDemo/images/icon02.jpg b/ASHMessageTableViewDemo/images/icon02.jpg new file mode 100644 index 0000000..bfb808a Binary files /dev/null and b/ASHMessageTableViewDemo/images/icon02.jpg differ diff --git a/ASHMessageTableViewDemo/images/toolbar_bottom_bar.png b/ASHMessageTableViewDemo/images/toolbar_bottom_bar.png new file mode 100755 index 0000000..b99556a Binary files /dev/null and b/ASHMessageTableViewDemo/images/toolbar_bottom_bar.png differ diff --git a/ASHMessageTableViewDemo/messages.plist b/ASHMessageTableViewDemo/messages.plist new file mode 100644 index 0000000..9511216 --- /dev/null +++ b/ASHMessageTableViewDemo/messages.plist @@ -0,0 +1,96 @@ + + + + + + content + 喂,2B! + icon + icon01.jpg + time + 前天 10:25 + type + 0 + + + content + 问你个严肃的事 + icon + icon01.jpg + time + 前天 10:25 + type + 0 + + + content + 你妹夫啊,你才2B!说,什么事? + icon + icon02.jpg + time + 昨天 20:05 + type + 1 + + + content + 你姐夫啊,我就想问下:你是不是我最好的朋友? + icon + icon01.jpg + time + 昨天 20:07 + type + 0 + + + content + 不借 + icon + icon02.jpg + time + 昨天 20:07 + type + 1 + + + content + 借你妹夫啊,哥又不穷,不是找你借钱。你就回答“是”或者“不是”。 + icon + icon01.jpg + time + 昨天 20:07 + type + 0 + + + content + + icon + icon02.jpg + time + 昨天 20:11 + type + 1 + + + content + 刚才看了部非常感人的电视剧,电视上说狗才是人类最好的朋友,所以我想确认一下 + icon + icon01.jpg + time + 昨天 20:15 + type + 0 + + + content + 你妈B的!!!滚!!! + icon + icon02.jpg + time + 昨天 20:15 + type + 1 + + + diff --git a/ASHMessageTableViewDemo/model/.DS_Store b/ASHMessageTableViewDemo/model/.DS_Store new file mode 100644 index 0000000..69c9a0c Binary files /dev/null and b/ASHMessageTableViewDemo/model/.DS_Store differ diff --git a/ASHMessageTableViewDemo/model/ChartMessage.h b/ASHMessageTableViewDemo/model/ChartMessage.h new file mode 100644 index 0000000..066f7eb --- /dev/null +++ b/ASHMessageTableViewDemo/model/ChartMessage.h @@ -0,0 +1,22 @@ +// +// ChartMessage.h +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// +typedef enum { + + kMessageFrom=0, + kMessageTo + +}ChartMessageType; +#import + +@interface ChartMessage : NSObject +@property (nonatomic,assign) ChartMessageType messageType; +@property (nonatomic, copy) NSString *icon; +//@property (nonatomic, copy) NSString *time; +@property (nonatomic, copy) NSString *content; +@property (nonatomic, copy) NSDictionary *dict; +@end diff --git a/ASHMessageTableViewDemo/model/ChartMessage.m b/ASHMessageTableViewDemo/model/ChartMessage.m new file mode 100644 index 0000000..2a71f96 --- /dev/null +++ b/ASHMessageTableViewDemo/model/ChartMessage.m @@ -0,0 +1,22 @@ +// +// ChartMessage.m +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import "ChartMessage.h" + +@implementation ChartMessage + +-(void)setDict:(NSDictionary *)dict +{ + _dict=dict; + + self.icon=dict[@"icon"]; +// self.time=dict[@"time"]; + self.content=dict[@"content"]; + self.messageType=[dict[@"type"] intValue]; +} +@end diff --git a/ASHMessageTableViewDemo/view/.DS_Store b/ASHMessageTableViewDemo/view/.DS_Store new file mode 100644 index 0000000..97133ea Binary files /dev/null and b/ASHMessageTableViewDemo/view/.DS_Store differ diff --git a/ASHMessageTableViewDemo/view/ChartContentView.h b/ASHMessageTableViewDemo/view/ChartContentView.h new file mode 100644 index 0000000..c03fdcf --- /dev/null +++ b/ASHMessageTableViewDemo/view/ChartContentView.h @@ -0,0 +1,24 @@ +// +// ChartContentView.h +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import +@class ChartContentView,ChartMessage; + +@protocol ChartContentViewDelegate + +-(void)chartContentViewLongPress:(ChartContentView *)chartView content:(NSString *)content; +-(void)chartContentViewTapPress:(ChartContentView *)chartView content:(NSString *)content; + +@end + +@interface ChartContentView : UIView +@property (nonatomic,strong) UIImageView *backImageView; +@property (nonatomic,strong) UILabel *contentLabel; +@property (nonatomic,strong) ChartMessage *chartMessage; +@property (nonatomic,assign) id delegate; +@end diff --git a/ASHMessageTableViewDemo/view/ChartContentView.m b/ASHMessageTableViewDemo/view/ChartContentView.m new file mode 100644 index 0000000..e77603b --- /dev/null +++ b/ASHMessageTableViewDemo/view/ChartContentView.m @@ -0,0 +1,63 @@ +// +// ChartContentView.m +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// +#define kContentStartMargin 25 +#import "ChartContentView.h" +#import "ChartMessage.h" +@implementation ChartContentView + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + + self.backImageView=[[UIImageView alloc]init]; + self.backImageView.userInteractionEnabled=YES; + [self addSubview:self.backImageView]; + + self.contentLabel=[[UILabel alloc]init]; + self.contentLabel.numberOfLines=0; + self.contentLabel.textAlignment=NSTextAlignmentLeft; + self.contentLabel.font=[UIFont fontWithName:@"HelveticaNeue" size:13]; + [self addSubview:self.contentLabel]; + + [self addGestureRecognizer: [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longTap:)]]; + + [self addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapPress:)]]; + } + return self; +} +-(void)setFrame:(CGRect)frame +{ + [super setFrame:frame]; + + self.backImageView.frame=self.bounds; + CGFloat contentLabelX=0; + if(self.chartMessage.messageType==kMessageFrom){ + + contentLabelX=kContentStartMargin*0.8; + }else if(self.chartMessage.messageType==kMessageTo){ + contentLabelX=kContentStartMargin*0.5; + } + self.contentLabel.frame=CGRectMake(contentLabelX, -3, self.frame.size.width-kContentStartMargin-5, self.frame.size.height); + +} +-(void)longTap:(UILongPressGestureRecognizer *)longTap +{ + if([self.delegate respondsToSelector:@selector(chartContentViewLongPress:content:)]){ + + [self.delegate chartContentViewLongPress:self content:self.contentLabel.text]; + } +} +-(void)tapPress:(UILongPressGestureRecognizer *)tapPress +{ + if([self.delegate respondsToSelector:@selector(chartContentViewTapPress:content:)]){ + + [self.delegate chartContentViewTapPress:self content:self.contentLabel.text]; + } +} +@end diff --git a/ASHMessageTableViewDemo/view/KeyBordVIew.h b/ASHMessageTableViewDemo/view/KeyBordVIew.h new file mode 100644 index 0000000..05c2b54 --- /dev/null +++ b/ASHMessageTableViewDemo/view/KeyBordVIew.h @@ -0,0 +1,23 @@ +// +// KeyBordVIew.h +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import + +@class KeyBordVIew; + +@protocol KeyBordVIewDelegate + +-(void)KeyBordView:(KeyBordVIew *)keyBoardView textFiledReturn:(UITextField *)textFiled; +-(void)KeyBordView:(KeyBordVIew *)keyBoardView textFiledBegin:(UITextField *)textFiled; +-(void)beginRecord; +-(void)finishRecord; +@end + +@interface KeyBordVIew : UIView +@property (nonatomic,assign) iddelegate; +@end diff --git a/ASHMessageTableViewDemo/view/KeyBordVIew.m b/ASHMessageTableViewDemo/view/KeyBordVIew.m new file mode 100644 index 0000000..0aa7602 --- /dev/null +++ b/ASHMessageTableViewDemo/view/KeyBordVIew.m @@ -0,0 +1,149 @@ +// +// KeyBordVIew.m +// 气泡 +// +// Created by zzy on 14-5-13. +// Copyright (c) 2014年 zzy. All rights reserved. +// + +#import "KeyBordVIew.h" +#import "ChartMessage.h" +#import "ChartCellFrame.h" + +@interface KeyBordVIew() +@property (nonatomic,strong) UIImageView *backImageView; +@property (nonatomic,strong) UIButton *voiceBtn; +@property (nonatomic,strong) UIButton *imageBtn; +@property (nonatomic,strong) UIButton *addBtn; +@property (nonatomic,strong) UIButton *speakBtn; +@property (nonatomic,strong) UITextField *textField; +@end + +@implementation KeyBordVIew + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code + [self initialData]; + } + return self; +} + +-(UIButton *)buttonWith:(NSString *)noraml hightLight:(NSString *)hightLight action:(SEL)action +{ + UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom]; + [btn setImage:[UIImage imageNamed:noraml] forState:UIControlStateNormal]; + [btn setImage:[UIImage imageNamed:hightLight] forState:UIControlStateHighlighted]; + [btn addTarget:self action:action forControlEvents:UIControlEventTouchUpInside]; + return btn; +} +-(void)initialData +{ + self.backImageView=[[UIImageView alloc]initWithFrame:self.bounds]; + self.backImageView.image=[UIImage strethImageWith:@"toolbar_bottom_bar.png"]; + [self addSubview:self.backImageView]; + + self.voiceBtn=[self buttonWith:@"chat_bottom_voice_nor.png" hightLight:@"chat_bottom_voice_press.png" action:@selector(voiceBtnPress:)]; + [self.voiceBtn setFrame:CGRectMake(0,0, 33, 33)]; + [self.voiceBtn setCenter:CGPointMake(30, self.frame.size.height*0.5)]; + [self addSubview:self.voiceBtn]; + + self.textField=[[UITextField alloc]initWithFrame:CGRectMake(0, 0, 180, self.frame.size.height*0.8)]; + self.textField.returnKeyType=UIReturnKeySend; + self.textField.center=CGPointMake(145, self.frame.size.height*0.5); + self.textField.font=[UIFont fontWithName:@"HelveticaNeue" size:14]; + self.textField.placeholder=@"请输入..."; + self.textField.background=[UIImage imageNamed:@"chat_bottom_textfield.png"]; + self.textField.delegate=self; + [self addSubview:self.textField]; + + self.imageBtn=[self buttonWith:@"chat_bottom_smile_nor.png" hightLight:@"chat_bottom_smile_press.png" action:@selector(imageBtnPress:)]; + [self.imageBtn setFrame:CGRectMake(0, 0, 33, 33)]; + [self.imageBtn setCenter:CGPointMake(260, self.frame.size.height*0.5)]; + [self addSubview:self.imageBtn]; + + self.addBtn=[self buttonWith:@"chat_bottom_up_nor.png" hightLight:@"chat_bottom_up_press.png" action:@selector(addBtnPress:)]; + [self.addBtn setFrame:CGRectMake(0, 0, 33, 33)]; + [self.addBtn setCenter:CGPointMake(300, self.frame.size.height*0.5)]; + [self addSubview:self.addBtn]; + + self.speakBtn=[self buttonWith:nil hightLight:nil action:@selector(speakBtnPress:)]; + [self.speakBtn setTitle:@"按住说话" forState:UIControlStateNormal]; + [self.speakBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal]; + [self.speakBtn addTarget:self action:@selector(touchDown:) forControlEvents:UIControlEventTouchDown]; + [self.speakBtn setTitleColor:[UIColor redColor] forState:(UIControlState)UIControlEventTouchDown]; + [self.speakBtn setBackgroundColor:[UIColor whiteColor]]; + [self.speakBtn setFrame:self.textField.frame]; + self.speakBtn.hidden=YES; + [self addSubview:self.speakBtn]; +} +-(void)touchDown:(UIButton *)voice +{ + //开始录音 + + if([self.delegate respondsToSelector:@selector(beginRecord)]){ + + [self.delegate beginRecord]; + } + NSLog(@"开始录音"); +} +-(void)speakBtnPress:(UIButton *)voice +{ + //结束录音 + + if([self.delegate respondsToSelector:@selector(finishRecord)]){ + + [self.delegate finishRecord]; + } + NSLog(@"结束录音"); +} +-(void)voiceBtnPress:(UIButton *)voice +{ + NSString *normal,*hightLight; + if(self.speakBtn.hidden==YES){ + + self.speakBtn.hidden=NO; + self.textField.hidden=YES; + normal=@"chat_bottom_keyboard_nor.png"; + hightLight=@"chat_bottom_keyboard_press.png"; + + }else{ + + self.speakBtn.hidden=YES; + self.textField.hidden=NO; + normal=@"chat_bottom_voice_nor.png"; + hightLight=@"chat_bottom_voice_press.png"; + + } + [voice setImage:[UIImage imageNamed:normal] forState:UIControlStateNormal]; + [voice setImage:[UIImage imageNamed:hightLight] forState:UIControlStateHighlighted]; +} +-(void)imageBtnPress:(UIButton *)image +{ + + +} +-(void)addBtnPress:(UIButton *)image +{ + + +} +-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField +{ + if([self.delegate respondsToSelector:@selector(KeyBordView:textFiledBegin:)]){ + + [self.delegate KeyBordView:self textFiledBegin:textField]; + } + return YES; +} +-(BOOL)textFieldShouldReturn:(UITextField *)textField +{ + if([self.delegate respondsToSelector:@selector(KeyBordView:textFiledReturn:)]){ + + [self.delegate KeyBordView:self textFiledReturn:textField]; + } + return YES; +} +@end