Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 21, 2012, 08:13 AM   #1
keolsen
macrumors newbie
 
Join Date: May 2008
Only left half of accessory button responds to touchupinside

Hi

As the title says, I have a problem implementing a button in an accessory view.
Let me explain...
I have a custom tableview controller and when the cells are being populated with content, the accessoryview is additionally set up containing a UIButton that calls a local function upon UIControlEventTouchUpInside.

It nearly works...but the button in the accessoryview only calls the action when I touch the left half of the button???

Some of my code is below...is it sufficient ?

Code:
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        Class listClass = NSClassFromString(self.listItemClass);
        cell = [[[listClass alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
        cell.textLabel.font = kItemFont;
        cell.textLabel.adjustsFontSizeToFitWidth = kItemFontShrink;
        cell.detailTextLabel.font = kItemSubtitleFont;
    }
    
    if (self.listItems != nil && self.listItems.count > indexPath.row) {
        NSDictionary *listItem = [self.listItems objectAtIndex:indexPath.row];
        
        cell.imageView.image = [UIImage imageNamed:[listItem objectForKey:kKeyItemIcon]];
        
        cell.textLabel.text = [[listItem objectForKey:kKeyItemText] uppercaseString];
        cell.detailTextLabel.text = [[listItem objectForKey:kKeyItemSubtitleText] uppercaseString];
        
        NSString *textColorString =[listItem objectForKey:kKeyItemTextColor];
        NSString *subtitleColorString =[listItem objectForKey:kKeyItemSubtitleTextColor];
        
        cell.textLabel.textColor = (textColorString != nil) ? [self _colorFromString:textColorString] : kItemFontColor;  
        cell.detailTextLabel.textColor = (subtitleColorString != nil) ? [self _colorFromString:subtitleColorString] : kItemSubtitleFontColor;
        
        NSDictionary *accessoryObject =[listItem objectForKey:kKeyItemAccessoryObject];
        if (accessoryObject != nil) {
            UIButton *accessoryButton = [UIButton buttonWithType:UIButtonTypeCustom];
            accessoryButton.frame = CGRectMake(0, 0, 200, 100);
            [accessoryButton setImage:[UIImage imageNamed:[accessoryObject objectForKey:kKeyAccessoryIcon]] forState:UIControlStateNormal];
            [accessoryButton setBackgroundColor:[UIColor blueColor]];
            [accessoryButton addTarget:self action:@selector(_didTapAccessoryButton: ) forControlEvents:UIControlEventTouchUpInside];
            [cell setAccessoryView:accessoryButton];
            
        } else {
            cell.accessoryView = nil;
        }
    } else {
        cell.imageView.image = [UIImage imageNamed:@"orange_cirkel"];
        cell.textLabel.text = @"LIST ITEM";
        cell.detailTextLabel.text = @"ADDITIONAL TEXT";
    }
    
    return cell;
}

Last edited by dejo; May 21, 2012 at 09:02 AM. Reason: Please use [code] tags.
keolsen is offline   0 Reply With Quote
Old May 21, 2012, 08:24 AM   #2
jnoxx
macrumors 65816
 
jnoxx's Avatar
 
Join Date: Dec 2010
Location: Aartselaar // Antwerp // Belgium
You type some weird code but anyhow, I think you're having an label over button issue, try changing the background of your labels and stuff, to see if it's coming over the button

Ciao.
__________________

iPad Mini, iPad 4, iPad 2, iPhone 3G,4,5, iMac 24", Mac Mini Last gen, Macbook Pro Retina with Dell U2711

Last edited by dejo; May 21, 2012 at 09:02 AM. Reason: Code tags added.
jnoxx is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
2011 27" iMac, left half of screen is dim Obioban iMac 7 Jul 10, 2013 01:25 PM
1% left = still have half your battery life to go on new iPhone5s Bobby Corwen iPhone 6 May 17, 2013 07:19 PM
iPhone 5 Power button half broken? Nyy8 iPhone 2 Jan 30, 2013 10:12 AM
Can you identify the issue with this 17in Intel iMac screen? PICTURE *Left half works hottyson iMac 1 Aug 11, 2012 07:50 PM

Forum Jump

All times are GMT -5. The time now is 04:07 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC