views:

78

answers:

2

Hi There,

This is a question for iPhone development and I'm hopin someone can point me to the right direction on how i should go about implementing this.

I am trying to write a chat application that supports emoticons/smileys. Where the smiley/emoticon images are stored can be figured out later. I think few iphone applications out there are already doing this (i.e. skype + ebuddy(?)) but not sure what method they went for.

After searching around, there seems to be a few ways of doing this (i think): - bubble chat style which has been discussed before. UITableViewController with custom UITableViewCell. For emoticons, might have to do a whole bunch of calculations to determine where to stick a UIImageView for each emoticon. - Use UIWebView as the whole "window". Style it to look like bubble chat. Takes away any manual calculations on image smiley placements.

I have no idea what the performance is like for each of these two methods, how complex it can get etc, so any comments and guidance will help for sure. Cheers

+1  A: 

If you use custom UITableViewCell, then I'd probably implement drawRect: instead of adding labels and images. One will probably take as long to implement as the other, but it will perform much better.

The UIWebView might be worth a short, although you will have to make sure that everything looks right there, too. Instead of using one big web page, I suggest simply throwing in a web view into each table view cell.

Personally I prefer the first approach, measuring and layout of text is not too complicated, but then I've never been the ultimate HTML guru.

Eiko
I see i see. I guess i have to get a better understanding of low level apis for drawrect, but for sure this is going to give me the greatest control on what i display. Oh boy there will be alot of string length/width calculations. i.e. if fit in x width, draw string, else wrap. If there is emoticon, can it fit etc etcWill see how it goes. thanks for the reply mate.
Bundee
A: 

I agree with @Eiko on making custom UITableViewCells, especially using drawRect instead of adding labels, images, etc.

If you used a UIWebView how would you handle updating it? A complete reload each time new text is sent? That seems like it will be a cause of issues. Once you get a long conversation reloading the entire UIWebView's contents will cause some flickering which isn't acceptable in my opinion. Also using a UIWebView would require you to have 2 complete copies of each conversation in memory. 1 as your backend data and 1 as the HTML. Where using a UITableView you have your backend data, and only enough of that will be duplicated that can fill 1 screen at a time.

jamone
I'm not too sure how i would handle it if the whole view is a UIWebView. I'm not too familiar with the UIWebView side of things yet. Maybe there is a way to inject html code on the fly? If not, then flickering is definitely going to happen.The other way @eiko was referring to was a UIWebview for each chat item that requires an emoticon. It might not be too bad if you do it only for chat items that have at least 1 emoticon. Otherwise, just a custom UITableViewCell. I do have alot of concerns on performance and memory usage tho.
Bundee
He could hook up javascript and change the page on the fly. On the plus side, UIWebView will let the user use copy and paste, which you are unlikely to implement on custom drawn views - at least not down to that level of detail.
Eiko