Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-05-2009, 01:51 PM   #1 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 5
dennis3484 is on a distinguished road
Default Performance issues of grouped UITableView on Device

Hey guys,

I am quite new to iPhone development but I am trying to build a small medical app.

The app consists of tab bar controller and in the first item is a navigation controller and a grouped UITableView. The problem is that scrolling the table on my iPhone 3G is pretty slow. It is not so smooth like in the Settings app. The performance in the Simulator is normal. My array consists of only 15 values so there's not much data.

I did a lot of searching and reading through Apple's documentation but I don't know what the problem is.

Thanks for any advice in advance!

Code:
//
//  UnfallTableViewController.h

#import <UIKit/UIKit.h>

@class UnfallDetailViewController;


@interface UnfallTableViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
	UITableView *unfallTableView;
	NSMutableArray *notfallArray;
	NSMutableArray *weitereArray;
	UnfallDetailViewController *unfallDetailViewController;
}

@property (nonatomic, retain) IBOutlet UITableView *unfallTableView;
@property (nonatomic, retain) NSMutableArray *notfallArray;
@property (nonatomic, retain) NSMutableArray *weitereArray;
@property (nonatomic, retain) UnfallDetailViewController *unfallDetailViewController;

@end
Code:
//
//  UnfallTableViewController.m

#import "UnfallTableViewController.h"
#import "UnfallDetailViewController.h"
#import "HomAid_004AppDelegate.h"


@implementation UnfallTableViewController

@synthesize unfallTableView;
@synthesize notfallArray;
@synthesize weitereArray;
@synthesize unfallDetailViewController;

- (void)viewDidLoad {
    [super viewDidLoad];
	
	self.title = NSLocalizedString(@"Unfall", @"Unfall Titel");
	
	NSMutableArray *array1 = [[NSMutableArray alloc] 
							  initWithObjects:
							  @"Haus", @"Freizeit", @"Verkehr", nil];
	NSMutableArray *array2 = [[NSMutableArray alloc] 
							  initWithObjects:
							  @"Eins", @"Zwei", @"Drei",
							  @"Vier", @"Fünf", @"Sechs",
							  @"Sieben", @"Acht", @"Neun",
							  @"Zehn", @"Elf", @"Zwölf", nil];
	
	self.notfallArray = array1;
	self.weitereArray = array2;
	
	[notfallArray release];
	[weitereArray release];
	
	UIBarButtonItem *info = [[UIBarButtonItem alloc] 
							 initWithTitle:@"Notruf"
							 style:UIBarButtonItemStyleBordered
							 target:self action:@selector(sosCall:)];
	
	self.navigationItem.rightBarButtonItem = info;
}

- (void)sosCall:(id)sender {
	NSLog(@"Notruf Button gedrückt");
	
	UIApplication *app = [UIApplication sharedApplication];
	NSString *urlString = [NSString stringWithFormat:@"tel:123456789"];
	NSURL *url = [NSURL URLWithString:urlString];
	[app openURL:url];
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	self.unfallTableView = nil;
	self.notfallArray = nil;
	self.weitereArray = nil;
	self.unfallDetailViewController = nil;
}


#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if(section == 0)
		return [notfallArray count];
	else
		return [weitereArray count];
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *UnfallTableIdentifier = @"UnfallTableIdentifier";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:UnfallTableIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc]
				 initWithStyle:UITableViewCellStyleDefault 
				 reuseIdentifier:UnfallTableIdentifier] autorelease];
    }
    
	NSUInteger row = [indexPath row];
	
	if(indexPath.section == 0)
		cell.textLabel.text = [notfallArray objectAtIndex:row];
	else
		cell.textLabel.text = [weitereArray objectAtIndex:row];
	
	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
		
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {	
	NSUInteger row = [indexPath row];
	if (self.unfallDetailViewController == nil) {
		UnfallDetailViewController *unfallDetail = [[[UnfallDetailViewController alloc] 
													initWithNibName:@"UnfallDetailView" 
													bundle:nil] autorelease];
		self.unfallDetailViewController = unfallDetail;
	}
	
	if(indexPath.section == 0)
		unfallDetailViewController.title = [NSString stringWithFormat:@"%@", [notfallArray objectAtIndex:row]];
	else
		unfallDetailViewController.title = [NSString stringWithFormat:@"%@", [weitereArray objectAtIndex:row]];
		
	[self.navigationController pushViewController:unfallDetailViewController animated:YES];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
	if (section == 0)
		return @"Notfall";
	else
		return @"weitere Unfälle";
}

- (void)dealloc {
	[unfallTableView release];
	[notfallArray release];
	[weitereArray release];
	[unfallDetailViewController release];
    [super dealloc];
}

@end
dennis3484 is offline   Reply With Quote
Old 09-05-2009, 11:30 PM   #2 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

The only thing jumping out at me is that you don't need to create a table view property for UITableViewControllers; they already have one. So it's possible you have two table views at the same time.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 09-06-2009, 04:50 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2009
Posts: 5
dennis3484 is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
The only thing jumping out at me is that you don't need to create a table view property for UITableViewControllers; they already have one. So it's possible you have two table views at the same time.
BrianSlick: Thanks for the advice. I removed the bold line in my UnfallTableViewController.h, but unfortunately no change:

Code:
//
//  UnfallTableViewController.h

#import <UIKit/UIKit.h>

@class UnfallDetailViewController;


@interface UnfallTableViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
	UITableView *unfallTableView;
	NSMutableArray *notfallArray;
	NSMutableArray *weitereArray;
	UnfallDetailViewController *unfallDetailViewController;
}

//@property (nonatomic, retain) IBOutlet UITableView *unfallTableView;
@property (nonatomic, retain) NSMutableArray *notfallArray;
@property (nonatomic, retain) NSMutableArray *weitereArray;
@property (nonatomic, retain) UnfallDetailViewController *unfallDetailViewController;

@end
dennis3484 is offline   Reply With Quote
Reply

Bookmarks

Tags
grouped, performance, scrolling, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 328
11 members and 317 guests
givensur, glenn_sayers, guusleijsten, ipodphone, jbro, mediaspree, mottdog, mtl_tech_guy, Punkjumper, vilisei, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:30 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0