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 08-07-2010, 12:40 PM   #1 (permalink)
Registered Member
 
lifeCoder45's Avatar
 
Join Date: Nov 2009
Location: Illinois
Posts: 92
lifeCoder45 is on a distinguished road
Send a message via AIM to lifeCoder45
Default More UITableViewCell Issues.

Hey guys. I'm having more issues with my UITableViewCells. First question is, is there a way to hide a subview of a cell while it is about to be deleted? As in when you click on the red circle and the delete button pops up? Can I detect that the delete button is there and hide it when it shows up?

And I have my subview (a label) set to use an autoresizing mask, so when I make the table editable the text slides to the left like it should, but once I delete a row, all of the other row's text just kinda slides to the right a bit, off the screen.

It is very strange.

Please see pics.



This is the table pre edit. Just fine.



This is editable, resizing fine.



This is why I want to just hide the right label.



This happens if I delete a cell, to all of the other ones.

Thanks so much!

- Josh
lifeCoder45 is offline   Reply With Quote
Old 08-07-2010, 02:20 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Yes, there is a delegate method in the TableView delegate protocol. The one that returns BOOL if you support a particular edit type. Then you check for Delete, make sure you return YES, saying you support DELETE, but also put code in there that can change that view to hidden.

I think that is the approach to use.

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Old 08-07-2010, 06:56 PM   #3 (permalink)
Registered Member
 
lifeCoder45's Avatar
 
Join Date: Nov 2009
Location: Illinois
Posts: 92
lifeCoder45 is on a distinguished road
Send a message via AIM to lifeCoder45
Default

Great! I'll look for it! Also I'm thinking that the label text is too far to the right after delete because when I reload the data, the x axis is too far to the right for the new cell, since that delete circle is on the right. Does this sound feasible? And how would I fix that? Would I need a different frame draw for the label?

Thanks!
lifeCoder45 is offline   Reply With Quote
Old 08-07-2010, 07:22 PM   #4 (permalink)
Registered Member
 
lifeCoder45's Avatar
 
Join Date: Nov 2009
Location: Illinois
Posts: 92
lifeCoder45 is on a distinguished road
Send a message via AIM to lifeCoder45
Default

Can I do something like this?

If self.table == is-editing

x=30

else

x=40

?

Sorry for the formatting, I'm on the iPhone ATM.
lifeCoder45 is offline   Reply With Quote
Old 08-08-2010, 10:25 AM   #5 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Well, if you put all your cell contents into the UITableViewCell's contentView property, it will automatically change the size.

Are you coding this view or using IB?

In IB, you should see the content view being an oval like button with a gray background.

If you are coding then just get add your subviews the cell's contentView property

[cell.contentView addSubView:mySubview];

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Old 08-08-2010, 10:45 AM   #6 (permalink)
Registered Member
 
lifeCoder45's Avatar
 
Join Date: Nov 2009
Location: Illinois
Posts: 92
lifeCoder45 is on a distinguished road
Send a message via AIM to lifeCoder45
Default

Here is my whole function for cellAt. I am adding the subview as you suggested, but like I said I think that since I'm calling this method while the table is in delete mode, the x part of the frame is too far to the right.

Code:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
	NSUInteger row = [indexPath row];
	
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
	}//end if
	
	NSArray *subviews = [[NSArray alloc] initWithArray:cell.contentView.subviews];
	for (UIView *subview in subviews) {
		[subview removeFromSuperview];
	}//end for
	[subviews release];	
	
	CGRect frame = CGRectMake (140, 12, 155, 22);
	
	UILabel *tempLabel = [[UILabel alloc] initWithFrame:frame];
	
	tempLabel.textAlignment = UITextAlignmentRight;
	
	NSString *tempString = [[NSString alloc] initWithFormat:@"%@",[[self.assets objectAtIndex:row] objectForKey:@"value"]];
	
	NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
	[formatter setNumberStyle: NSNumberFormatterCurrencyStyle];
	NSString *numberAsString = [formatter stringFromNumber:[NSNumber numberWithDouble:[tempString doubleValue]]];
	
	tempLabel.text = numberAsString; 
	
	tempLabel.backgroundColor = [UIColor clearColor];
	
	tempLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
	
	[cell.contentView addSubview:tempLabel];
	
	[tempLabel release];
	[tempString release];
	[formatter release];
	
	cell.textLabel.text = [[self.assets objectAtIndex:row] objectForKey:@"name"];
	cell.detailTextLabel.text = [[self.assets objectAtIndex:row] objectForKey:@"notes"];
	
    return cell;
	
}
lifeCoder45 is offline   Reply With Quote
Old 08-08-2010, 08:38 PM   #7 (permalink)
Registered Member
 
lifeCoder45's Avatar
 
Join Date: Nov 2009
Location: Illinois
Posts: 92
lifeCoder45 is on a distinguished road
Send a message via AIM to lifeCoder45
Default

Bump.

- Josh
lifeCoder45 is offline   Reply With Quote
Old 08-09-2010, 08:17 AM   #8 (permalink)
Registered Member
 
lifeCoder45's Avatar
 
Join Date: Nov 2009
Location: Illinois
Posts: 92
lifeCoder45 is on a distinguished road
Send a message via AIM to lifeCoder45
Default

Bump 2.

- Josh
lifeCoder45 is offline   Reply With Quote
Old 08-09-2010, 05:46 PM   #9 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

I am not sure the properties, but you have to set a couple more on your UILabel as to if it is bound to the right side of the view, left side etc. Like in Interface Builder how you can go to the ruler tab and they have that box where you click on it and it turns on a line outside the box or inside the box. Not sure what that is called. But in IB when you click on those lines it sets properties as to whether on resize it should stay you x setting from the left etc.

I'd check out the properties for that.

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Reply

Bookmarks

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: 315
9 members and 306 guests
arash5500, gordo26, HemiMG, linkmx, mediaspree, nobstudio, Objective Zero, stanny, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

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