I have a 'detail' page where I am displaying info for a club. The page is a UIViewController and consists of buttons and labels to acheive this look (like small grouped tables). When I load this page on a device, it lags a bit, more than any other view in my app.
I assume its because I have quite a few objects on the view controller. Does anyone have any suggestions on how to reduce this lag? Or how to achieve the look the 3 smaller tables like this(grouped) in a different way?
Thanks.
SCREENSHOT:
You could try making custom tablecells and use UITableView instead?
You could just make the view a UITableView using UITableViewStyleGrouped style, and then programmatically create the cells for each row. Overriding
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
gets you your titles like "Meeting Information" and "Contact", and overriding
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
gets you correct sizing on each table cell. If the text in "General Information" is not going to be a constant size, you can use the
-sizeWithFont::(UIFont *)font
method of NSString in your heightForRowAtIndexPath implementation.
The issue is not likely your interface design. UI drawing is pretty snappy usually. The things that slow it down are accessing data. If you have a large data set you are searching you might look at ways to speed that up.
Related
I wonder which view is used in the next image?
UITableView or UIWebView?
I always wondered how one can tell if a view is embedded inside a web view or not.
Anyway, anyone knows the answer for this specific view?
You can set individual height to individual UITableViewCell using this delegate Method
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
I'm building a settings screen for an iPhone app and it is supposed to resemble a grouped table view. Each "cell" should behave like a button. Most cells just have a image view, label view, and disclosure indicator. One will display a value in addition to a label. All of these buttons will present a new view when tapped.
Now, how to implement this? I was considering just laying out a set of buttons with custom background images, or would it be best to just use a table view. If that's the case what should it be implemented. So far I've only used table views to display some kind of dynamic data in which each cell displayed the same basic detail view. I'm most curious to figure out how to setup cellForRowAtIndexPath. Would this contain some sort of switch statement to configure each cell individually, or is there an easier way to handle all this?
InAppSettingsKit is an open source project that recreates the settings app inside your app for UI consistency. You can pick it apart for your answers.
You'll want to use a UITableViewController with the sections set to be UITableViewStyleGrouped.
Each of the groups is a section, so you'll want to return how many sections you have with - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView.
For every section, you want to specify how many rows there are with - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section.
You'll want to customize each cell with - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath (which, by the way, tells you which section's particular row you're modifying in the indexPath variable).
Finally, you'll want to handle the row click in - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath, using the pattern XCode provides for you:
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
Hope this helps!
Settings should go under the Settings 'App' on the iPhone. Your own App settings are incorporated into the standard Settings by adding a Settings.bundle to your own App.
It's straight-forward, and style-conformant.
How to do this is described here:
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Preferences/Preferences.html%23//apple_ref/doc/uid/TP40007072-CH6-SW1
Firstly, if your application have settings which are not frequently modified you should prefer creating a settings bundle. but if you need to change the settings frequently from within you app like in a game, you should create settings screen by yourself.
Most of the cases the screen should match the settings default screen. For this you must make use of tableView with customized cells. You can make use of following controls inside the table cells depending on your settingtype.
1. alabel---for static text,
2. a switch --- for settings with two values(ON/OFF or o/1 or any two set of values) e.g. nightMode on/off,
3. a slider ---- for specifying range of values e.g brightness etc.
This you can configure in table view's cellForRowIndex delegate method on basis of the row index. You can also create sections to group similar types of settings under one type.
Is there a way to add delete controls, like in UITableViewCell, on a table section? I see two ways:
Use table cell instead of sections.
Write own UIView section class, which will show delete controls.
Regarding the first way - as I think, it could be an easiest way in my situation.
The second way may be better from the implementation point of view, but it will take more time.
May be I missed another way? Any suggestions?
The only way I see is to provide your UITableViewController Delegate or Subclass with the method called:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
This gives you the power to display any kind of UIView as a section-header. within this view you can place controls that enable the user to delete sections.
I hope this helps a bit.
I have created an application in which i have to add users to the sqlite database.
Now the problem is I want the look of the standard iPhone Contact application Where while adding user we have the width of first cell smaller than other cells and the image before that cell..
Can you please give me the idea how such thing is possible.
How to make one cell small and rest others of normal size..
Thanks for any help in advance
There are three UITableViewDelegate messages you can listen for to adjust height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
However, even thought I didn't write Contacts.app I have a feeling they are also using
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
To adjust the views as well. Remember, you don't have to pack everything into a single monolithic custom table view cell. You can create multiple custom table view cells and load them each appropriately depending on the index path.
The contact detail view is a grouped tableview. Each cluster of cells is a section. The top section is a single custom cell with two subviews that look like squashed tableview cells. The left view shows the contact's photo. The right view shows the name.
To reproduce, create a custom UITableView subclass and lay it out like you want either programmatically or in Interface Builder. Then in the tableview delegate's cellForRowAtIndexPath check indexPath.section and return the proper row for the section.
It appears that the Contacts app uses a custom tableHeaderView when presenting the contact details with an image and label. A similar implementation is included in the sample project iPhoneCoreDataRecipes. The RecipeDetailView loads a separate nib in tableViewHeaderView that is used to set the tableView.tableHeaderView property. Have a look at RecipeDetailViewController.{h,m} and DetailHeaderView.xib. When the Contacts app switches to editing mode, the headerView appears to be swapped out for another view that has a button and a tableView with a single cell. This will allow you to set up a separate tableViewDelegate to handle the Name parts of the contact and a delegate to handle the address / telephony details.
How can I go about creating a UITableView with taller cells? Basically, I want to create a full screen table with only four cells, but they should take up the entire screen (1/4 each).
Assuming this is possible using a UITableView, can it be done both in code and in Interface Builder? And also, can each cell have its own height?
--Tim
Just use the -tableView:heightForRowAtIndexPath: method from the UITableViewDelegate protocol to customize the height of each cell. Something like this works just fine:
- (CGFloat)tableView:(UITableView *)tv heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 70.0f;
}
Hope that helps.
For best performance, if all your rows are the same height, use the rowHeight property. It's accessible from both code and Interface Builder.
If you want to customise individual row heights, then you need to implement the - tableView:heightForRowAtIndexPath: delegate method. It's a little slower performing, but more flexible.