iOS is getting fragmented. More devices to support with major iPhone hardware differences (0-2 cameras, no telephony - 3G - CDMA), screen resolutions (original, double, iPad) and especially more older operating system versions out in the wild.
To reach as many users as possible you have to check whether something exists before you try to use it. Customizing code based on iOS version number is possible, but there are other ways to do it.
Showing posts with label NSClassFromString. Show all posts
Showing posts with label NSClassFromString. Show all posts
Sunday, January 16, 2011
How to Check if iOS Supports Class, Method or Keyword
Labels:
Class,
conformsToProtocol,
fragmentation,
iOS4,
NSClassFromString,
NSDictionary,
NSString,
objectForKey,
protocol,
respondsToSelector,
selector
Thursday, October 14, 2010
How to Control UISearchBar Background Color
When you have a list, you want to search it. How would you do that? No, don't code it by yourself. Done it, removed it.
By default each UITableView comes with search support via a built-in UISearchDisplayController. You just add and connect UISearchBar to your table in Interface Builder and provide some delegate methods to make it work. Pretty easy:
You can fix that by doing two things. First get rid of default background:
Sad to think how many hours I wasted experimenting Things That Will Not Work, just to find out that kind of miniscule solution. Also bet that this will not work one year from now...
By default each UITableView comes with search support via a built-in UISearchDisplayController. You just add and connect UISearchBar to your table in Interface Builder and provide some delegate methods to make it work. Pretty easy:
self.searchDisplayController.delegate =Controlling how your UISearchBar looks like is a bit more difficult. If you want to show search box and some other component(s) side by side, you can do it by putting UIToolbar at back and a short UISearchBar on top of it. By default their backgrounds are different, looking pretty ugly together. Like a hack, what it really is.
self.searchDisplayController.searchBar.delegate =
self.searchDisplayController.searchResultsDataSource =
self.searchDisplayController.searchResultsDelegate = self.mySearchObject;
You can fix that by doing two things. First get rid of default background:
for (UIView *view in self.searchBar.subviews)...and the second thing? Something that will be extremely hard to find out, unless you get it right by accident? You have to set UISearchBar style Black Translucent!
{
if ([view isKindOfClass:NSClassFromString
(@"UISearchBarBackground")])
{
[view removeFromSuperview];
break;
}
}
Sad to think how many hours I wasted experimenting Things That Will Not Work, just to find out that kind of miniscule solution. Also bet that this will not work one year from now...
Labels:
delegate,
interface builder,
isKindOfClass,
NSClassFromString,
UISearchBarBackground,
UISearchDisplayController,
UITableView,
UIToolbar,
UIView
Subscribe to:
Posts (Atom)