Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed autoscroll issue #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions DemoProject/SOSimpleChatDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
3EBD811A191A61F90007B68A /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 3EBD8116191A61F90007B68A /* [email protected] */; };
3EBD811B191A61F90007B68A /* bubble_rect_sending.png in Resources */ = {isa = PBXBuildFile; fileRef = 3EBD8117191A61F90007B68A /* bubble_rect_sending.png */; };
3EBD811C191A61F90007B68A /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 3EBD8118191A61F90007B68A /* [email protected] */; };
3ED720E9197CF32200393C27 /* Type4VC.m in Sources */ = {isa = PBXBuildFile; fileRef = 3ED720E8197CF32200393C27 /* Type4VC.m */; };
75493C1219070071006C6BCD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75493C1119070071006C6BCD /* Foundation.framework */; };
75493C1419070071006C6BCD /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75493C1319070071006C6BCD /* CoreGraphics.framework */; };
75493C1619070071006C6BCD /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 75493C1519070071006C6BCD /* UIKit.framework */; };
Expand Down Expand Up @@ -88,6 +89,8 @@
3EBD8116191A61F90007B68A /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
3EBD8117191A61F90007B68A /* bubble_rect_sending.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bubble_rect_sending.png; sourceTree = "<group>"; };
3EBD8118191A61F90007B68A /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
3ED720E7197CF32200393C27 /* Type4VC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Type4VC.h; sourceTree = "<group>"; };
3ED720E8197CF32200393C27 /* Type4VC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Type4VC.m; sourceTree = "<group>"; };
75493C0E19070071006C6BCD /* SOSimpleChatDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SOSimpleChatDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
75493C1119070071006C6BCD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
75493C1319070071006C6BCD /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -310,6 +313,8 @@
3EBD8108191A4D0A0007B68A /* Type2VC.m */,
3EBD810A191A4D2B0007B68A /* Type3VC.h */,
3EBD810B191A4D2B0007B68A /* Type3VC.m */,
3ED720E7197CF32200393C27 /* Type4VC.h */,
3ED720E8197CF32200393C27 /* Type4VC.m */,
);
path = Controllers;
sourceTree = "<group>";
Expand Down Expand Up @@ -500,6 +505,7 @@
3EBD810C191A4D2B0007B68A /* Type3VC.m in Sources */,
75B35A3C1922B80800513423 /* SOMessagingViewController.m in Sources */,
75B35A3A1922B80800513423 /* SOMessageCell.m in Sources */,
3ED720E9197CF32200393C27 /* Type4VC.m in Sources */,
3E207894193DFC6300EC9FA4 /* Message.m in Sources */,
3EBD8109191A4D0A0007B68A /* Type2VC.m in Sources */,
75493C1E19070071006C6BCD /* main.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75493C0D19070071006C6BCD"
BuildableName = "SOSimpleChatDemo.app"
BlueprintName = "SOSimpleChatDemo"
ReferencedContainer = "container:SOSimpleChatDemo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75493C2E19070071006C6BCD"
BuildableName = "SOSimpleChatDemoTests.xctest"
BlueprintName = "SOSimpleChatDemoTests"
ReferencedContainer = "container:SOSimpleChatDemo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75493C0D19070071006C6BCD"
BuildableName = "SOSimpleChatDemo.app"
BlueprintName = "SOSimpleChatDemo"
ReferencedContainer = "container:SOSimpleChatDemo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75493C0D19070071006C6BCD"
BuildableName = "SOSimpleChatDemo.app"
BlueprintName = "SOSimpleChatDemo"
ReferencedContainer = "container:SOSimpleChatDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "75493C0D19070071006C6BCD"
BuildableName = "SOSimpleChatDemo.app"
BlueprintName = "SOSimpleChatDemo"
ReferencedContainer = "container:SOSimpleChatDemo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SOSimpleChatDemo.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>75493C0D19070071006C6BCD</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>75493C2E19070071006C6BCD</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
33 changes: 29 additions & 4 deletions DemoProject/SOSimpleChatDemo/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="mbQ-bf-1eT">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="mbQ-bf-1eT">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
Expand All @@ -17,7 +17,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="KWH-Tn-PUN" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-25" y="-376"/>
<point key="canvasLocation" x="-5" y="-760"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="oCt-f9-xip">
Expand Down Expand Up @@ -72,6 +72,16 @@
<segue destination="zhy-VN-k71" kind="push" id="17B-tk-JxH"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="PgF-ga-3ut">
<rect key="frame" x="92" y="349" width="136" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Type 4">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<segue destination="o9o-Cr-tMa" kind="push" id="4Vb-zX-1wk"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
Expand All @@ -94,7 +104,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="2kJ-rC-amP" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-25" y="374"/>
<point key="canvasLocation" x="-5" y="-10"/>
</scene>
<!--Type3VC - Messaging-->
<scene sceneID="gbx-Yu-aEw">
Expand All @@ -109,7 +119,22 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="6MS-Jv-qkx" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-25" y="1124"/>
<point key="canvasLocation" x="-5" y="776"/>
</scene>
<!--Type4VC - Messaging-->
<scene sceneID="tlj-cC-WLV">
<objects>
<viewController id="o9o-Cr-tMa" customClass="Type4VC" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="dgQ-XS-tzl">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" title="Messaging" id="Yq5-Ss-arI"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="X0Q-ko-euE" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-5" y="1540"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
Expand Down
28 changes: 15 additions & 13 deletions DemoProject/SOSimpleChatDemo/Sources/Controllers/Type3VC.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,25 @@ - (void)configureMessageCell:(SOMessageCell *)cell forMessageAtIndex:(NSInteger)
//-----------------------------------------------//
// Adding datetime label under balloon
//-----------------------------------------------//
UILabel *label = [self generateLabelForCell:cell];

UILabel *existingLabel = [[cell.contentView.subviews filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"tag == %d",label.tag]] lastObject];;
[existingLabel removeFromSuperview];

[cell.contentView addSubview:label];
[self generateLabelForCell:cell];
//-----------------------------------------------//
}

- (UILabel *)generateLabelForCell:(SOMessageCell *)cell
- (void)generateLabelForCell:(SOMessageCell *)cell
{
static NSInteger labelTag = 90;

Message *message = (Message *)cell.message;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd.MM.yyyy HH:mm"];
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:8];
label.textColor = [UIColor grayColor];
label.tag = 90;
UILabel *label = (UILabel *)[cell.contentView viewWithTag:labelTag];
if (!label) {
label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:8];
label.textColor = [UIColor grayColor];
label.tag = labelTag;
[cell.contentView addSubview:label];
}
label.text = [formatter stringFromDate:message.date];
[label sizeToFit];
CGRect frame = label.frame;
Expand All @@ -119,13 +120,14 @@ - (UILabel *)generateLabelForCell:(SOMessageCell *)cell
if (message.fromMe) {
frame.origin.x = cell.contentView.frame.size.width - cell.userImageView.frame.size.width - frame.size.width - rightMargin;
frame.origin.y = cell.containerView.frame.origin.y + cell.containerView.frame.size.height + topMargin;
label.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
} else {
frame.origin.x = cell.containerView.frame.origin.x + cell.userImageView.frame.origin.x + cell.userImageView.frame.size.width + leftMargin;
frame.origin.y = cell.containerView.frame.origin.y + cell.containerView.frame.size.height + topMargin;
label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
}
label.frame = frame;

return label;
label.frame = frame;
}

- (UIImage *)balloonImageForSending
Expand Down
13 changes: 13 additions & 0 deletions DemoProject/SOSimpleChatDemo/Sources/Controllers/Type4VC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Type4VC.h
// SOSimpleChatDemo
//
// Created by Artur Mkrtchyan on 7/21/14.
// Copyright (c) 2014 SocialOjbects Software. All rights reserved.
//

#import "SOMessagingViewController.h"

@interface Type4VC : SOMessagingViewController

@end
Loading