1

JSQMessageViewController でチャット バブルを取得していませんが、IOS のチャット ページでチャット バブルを取得するために追加するメソッドを取得できません。私を助けてください。

 //  .h File content
        //  ChatpageViewController.h
        //  ChatApp


    #import <UIKit/UIKit.h>
    #import <JSQMessagesViewController/JSQMessages.h>
    #import <JSQMessagesViewController.h>
    #import "JSQMessagesCollectionViewFlowLayout.h"
    #import "JSQMessages.h"
    #import "JSQPhotoMediaItem.h"
    #import "JSQLocationMediaItem.h"
    #import "JSQVideoMediaItem.h"
    #import "JSQMessagesMediaViewBubbleImageMasker.h"
    #import "JSQMessagesAvatarImage.h"
    #import "JSQMessagesAvatarImageFactory.h"
    #import "JSQMessagesBubbleImage.h"
    #import "JSQMessagesBubbleImageFactory.h"
    #import "UIImage+JSQMessages.h"



    @interface ChatpageViewController : JSQMessagesViewController<JSQMessagesCollectionViewDataSource,JSQMessagesCollectionViewDelegateFlowLayout,JSQMessagesCollectionViewCellDelegate,JSQMessageData,JSQMessageMediaData,JSQMessageAvatarImageDataSource,JSQMessageBubbleImageDataSource>

    @property(nonatomic,strong)NSDictionary * receivedict;


    @property (strong, nonatomic) IBOutlet UILabel *name;
    @property (strong, nonatomic) IBOutlet UILabel *mobile;
    - (IBAction)cancelbtn:(id)sender;


    @end

Mファイルはここから始まります

//
//  ChatpageViewController.m
//  ChatApp
//


#import "ChatpageViewController.h"


@interface ChatpageViewController ()
{

}

@end

@implementation ChatpageViewController
@synthesize receivedict,name,mobile;




-(void)viewWillAppear:(BOOL)animated
{

    self.collectionView.collectionViewLayout.springinessEnabled = YES;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
       // Do any additional setup after loading the view.
    [self.navigationController setNavigationBarHidden:YES animated:YES];
NSLog(@"%@",receivedict);
    name.text = [receivedict objectForKey:@"Name"];
    id.text =[receivedict objectForKey:@"Id"];



}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSString *)senderId
{
    return [receivedict objectForKey:@"Id"];
}


- (NSString *)senderDisplayName
{

    return [receivedict objectForKey:@"Name"];
}

- (NSDate *)date
{
    return 18/03/2016;
}


- (void)didPressSendButton:(UIButton *)button withMessageText:(NSString *)text senderId:(NSString *)senderId senderDisplayName:(NSString *)senderDisplayName date:(NSDate *)date
{

    [JSQSystemSoundPlayer jsq_playMessageSentSound];

    JSQMessage *message = [[JSQMessage alloc] initWithSenderId:senderId
                                             senderDisplayName:senderDisplayName
                                                          date:date
                                                          text:text];
   // [demoData.messages addObject:message];
    [self finishSendingMessageAnimated:YES];


    NSLog(@"%@",message);
}



- (IBAction)cancelbtn:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
@end
4

2 に答える 2

0

コーディングに次のメソッドを追加した後に試してみたところ、次の投稿の他の関数でバブルが表示されました-(void)didPressSendButton:(UIButton *)ボタンなど.

- (id<JSQMessageBubbleImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView messageBubbleImageDataForItemAtIndexPath:(NSIndexPath *)indexPath
{
    JSQMessage *message = [fularray objectAtIndex:indexPath.item];

    if ([message.senderId isEqualToString:self.senderId]) {
        return self.outgoingBubbleImageData;
    }

    return self.incomingBubbleImageData;
}

- (id<JSQMessageAvatarImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView avatarImageDataForItemAtIndexPath:(NSIndexPath *)indexPath {
    return [JSQMessagesAvatarImageFactory avatarImageWithUserInitials:@"JL" backgroundColor:[UIColor blueColor] textColor:[UIColor whiteColor] font:[UIFont systemFontOfSize:12.0] diameter:30.0];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return [fularray count];
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (id<JSQMessageData>)collectionView:(JSQMessagesCollectionView *)collectionView messageDataForItemAtIndexPath:(NSIndexPath *)indexPath {
    return fularray[indexPath.row];
}
于 2016-03-22T07:13:58.643 に答える