[iPhone高级] 基于XMPP的IOS聊天客户端程序(IOS端一)
介绍完了服务器,这篇我们就要介绍重点了,写我们自己的IOS客户端程序
先看一下我们完成的效果图
首先下载xmppframework这个框架,下载
点ZIP下载
接下来,用Xcode新建一个工程
将以下这些文件拖入新建工程中
加入framework
并设置
到这里我们就全部设好了,跑一下试试,看有没有错呢
如果没有错的话,我们的xmppframework就加入成功了。
我们设置我们的页面如下图:
我们的KKViewController.h
KKLoginController.m
这里着重的还是UITableViewKKChatController.m
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1;}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [messages count];}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *identifier = @"msgCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier]; } NSMutableDictionary *dict = [messages objectAtIndex:indexPath.row]; cell.textLabel.text = [dict objectForKey:@"msg"]; cell.detailTextLabel.text = [dict objectForKey:@"sender"]; cell.accessoryType = UITableViewCellAccessoryNone; return cell; }这些都比较简单,相信大家应该都能看得懂把这些都设置好以后,我们就要着重介绍XMPP了,怕太长了,接下一章吧。