0

Problème lors de l'obtention de la barre de navigation à l'aide de JSQMessagesViewController, j'ai essayé d'obtenir la barre de navigation dans mon projet, mais je n'ai pas réussi à l'obtenir. S'il vous plaît laissez-moi savoir quelles sont les méthodes doivent être ajoutées pour l'obtenir.Je ne suis pas en mesure d'obtenir la barre de navigation en utilisant JSQMessagesViewController

#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" 
#import "Chat.h" 

@interface ChatpageViewController : JSQMessagesViewController 
{ 
NSMutableArray * fularray; 
} 
@property(nonatomic,strong)NSDictionary * receivedict; 

@property (strong, nonatomic) IBOutlet UILabel *name; 
@property (strong, nonatomic) IBOutlet UILabel *mobile; 

@property (strong, nonatomic) JSQMessagesBubbleImage *outgoingBubbleImageData; 
@property (strong, nonatomic) JSQMessagesBubbleImage *incomingBubbleImageData; 

@end 

#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]; 

    fularray = [[NSMutableArray alloc] init]; 
    // Do any additional setup after loading the view. 
    // [self.navigationController setNavigationBarHidden:NO animated:YES]; 
    NSLog(@"%@",receivedict); 
    name.text = [receivedict objectForKey:@"Name"]; 
    mobile.text =[receivedict objectForKey:@"Mobile"]; 

    JSQMessagesBubbleImageFactory *bubbleFactory = [[JSQMessagesBubbleImageFactory alloc] init]; 

    self.outgoingBubbleImageData = [bubbleFactory outgoingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleBlueColor]]; 
    self.incomingBubbleImageData = [bubbleFactory incomingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleLightGrayColor]]; 

    } 

    (id)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)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)collectionView:(JSQMessagesCollectionView *)collectionView messageDataForItemAtIndexPath:(NSIndexPath *)indexPath { 
    return fularray[indexPath.row]; 
    } 

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

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

    (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]; 

    [fularray addObject:message]; 
    [self.collectionView reloadData]; 
    [self finishSendingMessageAnimated:YES]; 
    NSLog(@"%@",message); 
    } 

Myproject est enregistré dans le lien: https://www.dropbox.com/s/ozih8ko9836fmb2/chatapp.zip?dl=0

+0

avez-vous résolu votre problème. Je ne pouvais pas obtenir votre exemple de code dropbox. joindre un échantillon et laissez-moi savoir. – ChenSmile

+0

Salut, oui Imran, je l'ai résolu. Merci. – VyTcdc

Répondre

1

Aller MainStoryboard-> sélectionnez votre Controller-> dans le menu choisissez Editor-> Intégrer dans -> Navigation Controller

+0

essayé de ne pas obtenir, Dans l'application de démonstration, je pense qu'ils utilisent le code ci-dessous, je ne comprenais pas pu quelqu'un me dire ce que la méthode que nous avons besoin d'utiliser pour obtenir la navigation DemoMessagesViewController * vc = [DemoMessagesViewController messagesViewController]; vc.delegateModal = self; UINavigationController * nc = [[UINavigationController alloc] initWithRootViewController: vc]; [self presentViewController: nc animé: YES achèvement: néant]; – VyTcdc

1

modification du fichier JSQMessagesViewController.m dans - (void) jsq_updateCollectionViewInsets

[self jsq_setCollectionViewInsetsTopValue: self.topContentAdditionalInset + 64 bottomValue: CGRectGetMaxY (self.collect ionView.frame) - CGRectGetMinY (self.inputToolbar.frame)];