2016-03-31 11 views
0

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

+0

haben Sie Ihr Problem gelöst. Ich konnte Ihren Dropbox-Beispielcode nicht erhalten. Probe anhängen und mich wissen lassen. – ChenSmile

+0

Hallo, ja Imran, ich habe es gelöst. Vielen Dank. – VyTcdc

Antwort

1

Goto MainStoryboard-> wählen Sie Ihre Controller-> in Menü wählen Editor-> Einbetten in -> Navigation Controller

+0

Versucht nicht immer, In der Demo-Anwendung Ich denke, sie den Balg-Code verwenden, ich einige man nicht mich verstehen konnte sagen, was die Methode, die wir Navigation verwenden müssen bekommen DemoMessagesViewController * vc = [DemoMessagesViewController messagesViewController]; vc.delegateModal = Selbst; UINavigationController * nc = [[UINavigationController Alloc] initWithRootViewController: vc]; [self presentViewController: nc animiert: YES completion: nil]; – VyTcdc

1

Änderung JSQMessagesViewController.m Datei in - (void) jsq_updateCollectionViewInsets

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