Monotouch.Dialog Customizing cells - iphone

I wanna customize cells in MonoTouch.Dialog.
For example make custom background in BoolElement and make custom image for this small bool thing that can be on or off, sorry forgot the name, or make custom disclosure indicator image in StringElement.
Is there simple way to do this without making own custom elements?

In some cases you'll need to create custom Element-derived types to customize cells. In other cases you will be able to add some custom code inside your application. FWIW I think it's cleaner to create your own everytime.
You can find a lot of examples in the Sample application that is available on github along with MonoTouch.Dialog (that includes having a custom background and totally owner-drawn elements).
There are also several questions (with answers) about common MonoTouch.Dialog customizations here on stackoverflow. Click on the monotouch.dialog tag and read them.
If you get stuck on a particular customization then don't hesitate to ask for help.

Related

What's the best way to customise all monotouch.dialog TableViewCells to the same style (Background, etc..)?

Im using Monotouch.Dialog. I'd like to customise the look and feel of the tables. Nothing too major, I can change the background of the tableview easily, the cell borders and use my own custom header and footer views.
What is the best way of customising ALL the cells displayed in a TableView?
Is there some point in the Monotouch.Dialog code I can intercept the generation of cells and customise them in one place, so they all, for example have the same background color, font type/color custom detail disclosure icon etc.
Or do I have to individually customise all the different types (BooleanElement, StringElement, FloatElement etc)
Note: Im aware I can use StyledString element, but this only covers the string element type. I want to customise all the cells displayed in my own custom style.
There is no easy way of doing this in the current codebase for MonoTouch.Dialog.
What you could try is the Beta for MonoTouch which comes with iOS5 bindings. If you are willing to only support iOS5, you can use the Appearance class to customize a few properties (not all, sadly). You can customize things like the background view across the board:
UIView.Appearance.BackgroundColor = UIColor.Red;
You could also take a look at https://github.com/RobertKozak/MonoMobile.Views which started as a fork from MonoTouch.Dialog but morphed into a similar but now totally different library. It has styling built in.

How to rebuild the email-app (specificly the mail-overview)?

I want to reabuild the email-app one to one for a private-message system.
I am working at the moment on the email-overview-screen.
Now I have a ViewController for this with a UITableView and a UINavigationBar on it.
2 simple questions:
How do I get more then one line in the cell, specificly 2-4
different font-types (bold / not bold / blue) exactly rebuilded as
seen in the link above?
How do I can add a PullDown-Refresh functionality? (You know, this
pull down, oh refrash, thing, emails have)
Use a custom cell, you can put in whatever information and links and styles as you want. You can even use UIWebViews as the cells, which could make styling and links easier.
Many examples of this have a look at the answers to this SO question.

Help with Application Settings

I'm developing the settings page for an iPhone application I'm working on. The basics are simple enough but there are some interesting things I've seen in the settings for some of the default iPhone and I was wondering if they are easy to create.
Two things in particular are having a UITextView as a child pane (an example of this is the signature in the Mail app settings) as well as having settings appear and disappear based on a switch (an example would be in the Wifi settings).
Any ideas if these are somewhat easily achievable?
EDIT: I'm aware I can achieve a similar effect by creating a custom settings page. What I want to know is if the things I mentioned are possible for application creators.
Use UITableView and build your custom subclasses of UITableViewCell class for various settings. You can easily manipulate a table view for making things appear and disappear dynamically.
As #Kakosquid suggested you can try a table view with custom cells. You can go through this tutorial for more info on custom cells

Is there a way to create custom UIDataDetectorTypes?

What I am trying to do is create tooltip functionality so that certain words in my instructional app can be tapped and the definition pops up. For the popup part I plan on using code from “AFInformationView” which provides bubbles on the iPhone.
The part I'm struggling with is how to associate A particular word's location with the bubble. Currently I have the text on a UILabel that is on a custom UITableCell. Since I calculate the row height on the fly with:
[textToUse sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:CGSizeMake(stop-start, 500)];
I'm not sure what the coordinates for a specific word will be. I was thinking that if I created a custom DataDetectorType that could be the fix.
If anyone knows how to do this or has any other ideas I would be happy to hear them.
Thanks,
Andrew
I didn't create a custom UIDataDetectorTypes but Craig Hockenberry did something like it with his TwitterrificTouch.
He uses regular expressions to detect links and other things. I provide it with my keywords and then they become tappable. He places buttons on top of the matching text from the underlying labels. You can google a lot of posts that talk about "putting transparent buttons on top" of various things but Craig's code is the only example/working code I could find.
Here is the link:
http://furbo.org/2008/10/07/fancy-uilabels/
I don't think this is possible. The (few) Data Detector types that the iPhone currently supports are hard-coded with a integer type id. There does not seem to be a mechanism to extends that list of types.
File a feature request in their bug tracker. I will do the same.
AFAIK, you can't create custom data detectors.
The best approach for this sort of thing seems to be using UIWebViews. At least that's what I did. However, you shouldn't use a UIWebView inside a UITableViewCell. In fact, no subview of a UITableViewCell should respond to user input. So I think the best approach would be to display a UIWebView when the cell is tapped.
UIWebViews could be a possible approach but on scrolling you should consider that the whole text should be parsed to detect the words.You could use HTMl tags to make them blue and provide the links.But how could i then assign a custom behavior then opening in safari?
If you want custom data detector you could write an extractor method to primarly patch the links with help of NSregularExpression. For example
NSString regex = #"(http|https|fb)://((\w)|([0-9]*)|([-|_]))+(\.|/)"; to patch alll the links including Facebook URLs inside text like fb://friends.
Then you could use NSattributedString yo mark the links with different colors etc.
ThreeTwenty has a great library called TTTAttributedLabel where you could assign links to certain parts of a text. I also scrolls quite fast if you use it in tableviews
https://github.com/mattt/TTTAttributedLabel

Settings-style grouped table

So it's trivial to create a Settings style table on the iPhone. The problem is, they add a great deal of code as your Settings have a gamut of options/styled cells. One section might have a check list, another might have cells with accessory disclosures to drill down further, another might be labels with UITextFields.
My question here is, what's the cleanest way to go about creating this table. Do you typically create a subclass of UITableViewController and then subclass UITableViewCell for each different type of cells, and write supporting classes for those cells? Meaning if you have a Settings style table with 4 sections, all different types of cells, you will load 4 nibs into the table and import 4 class files? Programmatically set the frame, views, textfields and tag them for later access?
The answer(s) to this is probably subjective, but I'd like to know what you experts consider the most elegant approach to this common problem.
The easiest way to do this is to simply add your controls during the tableView:cellForRowAtIndexPath: method.
I also recommend this to help corral your code:
A technique for using UITableView and retaining your sanity
I would rather set most of the settings that I can in Interface Builder, instead of writing a whole bunch of code to make the visual/layout just right. As you can imagine, it will take quite a few rounds of "modify - build - test" in the iPhone Simulator to get this special table view laid out the way you want it.
I feel it's probably a bit easier to do all of these rough visual changes in IB, then load all of the custom UITableViewCell dynamically via their identifiers in code. You could then do one final round of tweaking on this code, if something that you want is not doable in IB.
Three20 library (extracted from Facebook iPhone app) has a set of ready-made cells that contain various controls.
(Not sure you want to use them, however. Three20 suffers from “not-invented-here” a little bit and tries to subclass and extend everything, so adding it adds quite a bit of a mess to your project. But at least you can use it as an example.)
P.S. Your question inspired me to open a “What are your favourite UITableView / UITableViewCell tricks?” thread on Stack Overflow, check it out for more tips.