iPhone即时消息客户端设计问题 [英] IPhone Instant message Client desgin problem

查看:62
本文介绍了iPhone即时消息客户端设计问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在iphone上编写IM客户端.//参考号:#IMClient01.这是我的初始设计:

I am writing an IM Client on iphone.// post ref: #IMClient01. Here is my initial design of it:

(UIView*)LogInWindow; // to log in
(UITabBarController*) MainTabBarController;//have three tabs, namely:Contacts, Chats, My Profile 
(UITableViewController*)ContactsController; //manages a list of contact/user
(UITableViewController*)ChatsController;    //manages a list of chat history, each row is a chat with a different person
(UIViewController *)ChatController; //manages a chat/conversation with a single user.

如同在iPhone上的Skype中一样,有两种启动对话/聊天的方法.您可以通过从联系人中点击用户来与Skype用户聊天,或者如果有与该用户相关的聊天记录,则可以点击聊天记录中的聊天记录.如果以上情况映射到我的控制器类:如果在ContactsController中点击一个单元格/行,则将ChatController推到顶视图.如果在ChatsController中点击一个单元格/行,则将ChatController推到顶视图.

As in Skype on IPhone, there are two ways to start a conversation/chat.You can either chat with a Skype user by tapping on the User from Contact or if there is a Chat History associated with the user, you can tap the Chat History in Chats. if the above scenario mapped to my controller classes: If Tapping a cell/row in ContactsController then push ChatController to top view. If Tapping a cell/row in ChatsController then push ChatController to top view.

在两次推入操作中,它类似于:

In the two push operations, it would something like:

[self.navigationController pushViewController:myChatController animated:YES];

我的第一个问题是myChatController应该是单例类吗?与在计算机上可以打开许多聊天窗口且每个窗口管理与另一个人的聊天的计算机不同,在iPhone中,只有一个顶视图/窗口,因此只能显示一个聊天窗口?

My first question is should myChatController be a singleton class? Unlike on computers,where you can have many chat windows open and each window manages a chat with a different person, in IPhone, there is only one top view/window, so only one chat window can be displayed?

我的第二个问题:如果ContactsController和ChatsController都有一个指向同一ChatController实例的ChatController实例变量,这将是一个好主意吗?那么,当点击ContactsController或ChatsController中的单元格/行时,是否将同一个ChatController实例推到顶视图以显示对话?

My second question: Would this be a good idea if ContactsController and ChatsController each has a ChatController instance variable that points to the same ChatController instance? So when a cell/row in ContactsController or ChatsController is tapped, the same ChatController instance is pushed to the top view to display the conversation?

我对自己的解释够清楚吗?如果有人可以提出建议,我将不胜感激.

Am I explaining myself clear enough? I would really appreciate if someone can give some suggestions.

推荐答案

与我对您的相关问题的回答一致,,您需要放弃导航控制器完全,并使用自定义代码管理视图的切换.

In keeping with my answer to your related question, back button goes back to a different UITableViewController from where it came from, you need to abandon the navigation controller entirely and manage the switching of views with custom code.

因此,您不必担心使用单例(无论如何在Objective-c中都很难做到.)也不用需要ContactsController和ChatsController真正了解ChatView,因为它们不会加载并显示它.取而代之的是,您将在自定义控制器中仅具有ChatView的单个属性,该属性用于管理所有视图的换出和选项卡的移动.

As such you don't need to worry about using a singleton (which is hard to do in Objective-c anyway.) Nor to you need for the ContactsController and ChatsController to really know about the ChatView because they won't be loading and displaying it. Instead you will just have single attribute for the ChatView in the custom controller that manages the swapping out of all the views and the shifting of tabs.

所有操作都非常麻烦且复杂,但是可以正常工作.

All very ungainly and complicated but it will work.

这篇关于iPhone即时消息客户端设计问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆