Problem beim Abrufen der Navigationsleiste mit JSQMessagesViewController, ich habe versucht, Navigationsleiste in meinem Projekt zu bekommen, aber es nicht bekommen. Bitte lassen Sie mich wissen, welche Methoden hinzugefügt werden müssen, um sie zu erhalten.Ich bin nicht in der Lage Navigationsleiste mit 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 wird in den Link gespeichert: https://www.dropbox.com/s/ozih8ko9836fmb2/chatapp.zip?dl=0
haben Sie Ihr Problem gelöst. Ich konnte Ihren Dropbox-Beispielcode nicht erhalten. Probe anhängen und mich wissen lassen. – ChenSmile
Hallo, ja Imran, ich habe es gelöst. Vielen Dank. – VyTcdc