I am using a UITableView in my application. I have the following questions:
-
I need to know when a user selected a row. From what I gather, I need to write a class that implements the
UITableViewDelegate. Then I need to override theRowSelectedmethod. Is there anyway to do this in my controller (as opposed to creating another class). It seems like overkill. Something likemyTableView.RowSelected += MyMethod(). I’m not sure whyRowSelectedis not an event in the first place… -
I want to clip the title of a
UITableView(text in the header) on the left hand side (default is the right). I know you can set theLineBreakMode, but it seems like I have to do this in theGetViewForHeadermethod (creating my ownUIViewthat is in the header). Is there a simpler way to do this?
MonoTouch offers (close to) full bindings to the iOS SDK – i.e. some stuff already exists in the .NET base class library and are not duplicated (but we’ll add them if you need them, just fill a bug report in such cases).
In general those bindings are very close to the original API (either C or Objective-C based) since:
the binding process is largely automated using the btouch tool supplied with MonoTouch (which you can use to bind your own ObjectiveC API);
it really helps porting existsing code, finding code samples and API documentation (Apple developer site, blogs, questions here on stackoverflow.com…)
Events, like .NET provides, do not exists in Objective-C. In many (but not all) cases MonoTouch added .NET-style events that allows you to avoid defining your own
xxxDelegatestypes. In general the events are namedOn+ the name of the delegate selector.In case of
UITableViewthe (ObjectiveC) API is IMHO a bit confusing – but there’s an alternative: MonoTouch.Dialog. It makes working with tables much easier and has a .NET-friendly API.p.s. please try to ask only one question per entry since you can’t mark multiple anwers as accepted. It also help people who looks for similar questions/answers on the site.