Permalink
Browse files

Fix some bug and so so .

  • Loading branch information...
RobinChao committed Dec 25, 2013
1 parent 52b3611 commit fbd9a03c0d1372854852c427314eed97c4b8e84f
@@ -630,7 +630,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.0;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
@@ -663,7 +663,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 6.0;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
@@ -758,6 +758,7 @@
AFC253C8183E3469001D7263 /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
AFC253C9183E3469001D7263 /* Build configuration list for PBXNativeTarget "ChatMessageTableViewControllerTests" */ = {
isa = XCConfigurationList;
@@ -766,6 +767,7 @@
AFC253CB183E3469001D7263 /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -12,4 +12,6 @@
@property (strong, nonatomic) UIWindow *window;
+@property (nonatomic,strong) UINavigationController *navigationController;
+
@end
@@ -7,12 +7,22 @@
//
#import "AppDelegate.h"
+#import "ViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
+ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
+
+ ViewController *mainViewController = [[ViewController alloc] init];
+ self.navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
+ self.window.rootViewController = self.navigationController;
+
+
+ [self.window makeKeyAndVisible];
+
return YES;
}
@@ -11,7 +11,7 @@
-@interface ViewController () <JSMessagesViewDelegate, JSMessagesViewDataSource, UIImagePickerControllerDelegate, UINavigationControllerDelegate>
+@interface ViewController () <JSMessagesViewDelegate, JSMessagesViewDataSource, UIImagePickerControllerDelegate, UINavigationControllerDelegate,UIActionSheetDelegate>
@property (strong, nonatomic) NSMutableArray *messageArray;
@property (nonatomic,strong) UIImage *willSendImage;
@@ -28,14 +28,15 @@ @implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
+
+ self.title = @"ChatMessage";
+
self.delegate = self;
self.dataSource = self;
- self.title = @"ChatMessage";
-
self.messageArray = [NSMutableArray array];
self.timestamps = [NSMutableArray array];
-
+
}
@@ -62,10 +63,28 @@ - (void)sendPressed:(UIButton *)sender withText:(NSString *)text
}
- (void)cameraPressed:(id)sender{
+
+ [self.inputToolBarView.textView resignFirstResponder];
+
+ UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"相册", nil];
+ [actionSheet showInView:self.view];
+}
+
+#pragma mark -- UIActionSheet Delegate
+-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
+
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
- picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
+
+ switch (buttonIndex) {
+ case 0:
+ picker.sourceType = UIImagePickerControllerSourceTypeCamera;
+ break;
+ case 1:
+ picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
+ break;
+ }
[self presentViewController:picker animated:YES completion:NULL];
}
@@ -185,24 +204,24 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
[self.messageArray addObject:[NSDictionary dictionaryWithObject:self.willSendImage forKey:@"Image"]];
[self.timestamps addObject:[NSDate date]];
-// [self.tableView reloadData];
NSInteger rows = [self.tableView numberOfRowsInSection:0];
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:rows inSection:0]] withRowAnimation:UITableViewRowAnimationBottom];
- [self.tableView endUpdates];
+ [self.tableView endUpdates];
+
+ [JSMessageSoundEffect playMessageSentSound];
[self scrollToBottomAnimated:YES];
[self dismissViewControllerAnimated:YES completion:NULL];
-
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:NULL];
-}
+}
@end
@@ -45,6 +45,11 @@ typedef enum {
@interface JSBubbleMessageCell : UITableViewCell
+
+@property (nonatomic, assign) BOOL isSelected;
+@property (nonatomic, readonly, strong) UIImageView *imageView;
+@property (nonatomic, readonly, strong) UIImage *renderedMark;
+
#pragma mark - Initialization
- (id)initWithBubbleType:(JSBubbleMessageType)type
bubbleStyle:(JSBubbleMessageStyle)bubbleStyle
@@ -237,7 +237,7 @@ - (void)drawRect:(CGRect)frame
{
if ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending)
{
- UIColor* textColor = [UIColor whiteColor];
+ UIColor* textColor = [UIColor blackColor];
if (self.selectedToShowCopyMenu)
textColor = [UIColor lightTextColor];
@@ -408,7 +408,7 @@ + (int)maxCharactersPerLine
+ (int)numberOfLinesForMessage:(NSString *)txt
{
- return (txt.length / [JSBubbleView maxCharactersPerLine]) + 1;
+ return (int)(txt.length / [JSBubbleView maxCharactersPerLine]) + 1;
}
@end
@@ -94,11 +94,14 @@ typedef enum {
@property (weak, nonatomic) id<JSMessagesViewDelegate> delegate;
@property (weak, nonatomic) id<JSMessagesViewDataSource> dataSource;
+
@property (strong, nonatomic) UITableView *tableView;
@property (strong, nonatomic) JSMessageInputView *inputToolBarView;
@property (assign, nonatomic) CGFloat previousTextViewContentHeight;
@property (assign, nonatomic, readonly) UIEdgeInsets originalTableViewContentInset;
+@property (nonatomic,strong) NSMutableArray *selectedMarks;
+
#pragma mark - Initialization
- (UIButton *)sendButton;
@@ -61,11 +61,11 @@ - (void)setup
CGSize size = self.view.frame.size;
- CGRect tableFrame = CGRectMake(0.0f, 40.0f, size.width, size.height - 40 - INPUT_HEIGHT);
+ CGRect tableFrame = CGRectMake(0.0f, 0.0f, size.width, size.height - INPUT_HEIGHT);
self.tableView = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStylePlain];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableView.dataSource = self;
- self.tableView.delegate = self;
+ self.tableView.delegate = self;
[self.view addSubview:self.tableView];
UIButton* mediaButton = nil;
@@ -122,6 +122,9 @@ - (void)setup
self.inputToolBarView.textView.frame = frame;
}
+
+ self.selectedMarks = [NSMutableArray new];
+
[self setBackgroundColor:[UIColor messagesBackgroundColor]];
}
@@ -263,9 +266,31 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[cell setMessage:[self.dataSource textForRowAtIndexPath:indexPath]];
[cell setBackgroundColor:tableView.backgroundColor];
+
+
+ cell.isSelected = [self.selectedMarks containsObject:CellID] ? YES : NO;
+
return cell;
}
+-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
+ JSBubbleMessageType type = [self.delegate messageTypeForRowAtIndexPath:indexPath];
+ JSBubbleMessageStyle bubbleStyle = [self.delegate messageStyleForRowAtIndexPath:indexPath];
+
+ BOOL hasTimestamp = [self shouldHaveTimestampForRowAtIndexPath:indexPath];
+ BOOL hasAvatar = [self shouldHaveAvatarForRowAtIndexPath:indexPath];
+
+ NSString *CellID = [NSString stringWithFormat:@"MessageCell_%d_%d_%d_%d", type, bubbleStyle, hasTimestamp, hasAvatar];
+
+ if ([self.selectedMarks containsObject:CellID])// Is selected?
+ [self.selectedMarks removeObject:CellID];
+ else
+ [self.selectedMarks addObject:CellID];
+
+ [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
+}
+
+
#pragma mark - Table view delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

0 comments on commit fbd9a03

Please sign in to comment.