Вопрос

I am building a custom table view (with a custom UITableViewCell) in iOS and I want the user to be able to swipe left and reveal a few buttons. There are several great pre-built classes already built that I have been referencing and leveraging to help me build this like the SWTableViewCell on gitHub https://github.com/CEWendel/SWTableViewCell

Here is my question...because my custom cell is fairly large height-wise from a design perspective I would like the buttons to stack vertically not horizontally. You can see the design below when the user swipes the cell left... (I was going to include the images but was not allowed because I am new to StackOverflow so hopefully the links work :)

http://i.stack.imgur.com/btACy.png

What would be the best way to accomplish this?

I am still very new to iOS programming (and programming in general) so any help would be greatly appreciated.

Thank you in advance for any help.

Это было полезно?

Решение

I would use the SWTableViewCell Library. Although with the current version it's not yet possible to have vertical aligned buttons. But you can overwrite the method, which is doing the positioning for the buttons:

- (void)populateUtilityButtons {
    NSUInteger utilityButtonsCounter = 0;
    for (UIButton *utilityButton in _utilityButtons) {

        // Here you would overwrite to use the y position and the height
        CGFloat utilityButtonXCord = 0;
        if (utilityButtonsCounter >= 1) utilityButtonXCord = _utilityButtonWidth * utilityButtonsCounter;
        [utilityButton setFrame:CGRectMake(utilityButtonXCord, 0, _utilityButtonWidth, CGRectGetHeight(self.bounds))];
        [utilityButton setTag:utilityButtonsCounter];
        [utilityButton addTarget:_parentCell action:_utilityButtonSelector forControlEvents:UIControlEventTouchDown];
        [self addSubview: utilityButton];
        utilityButtonsCounter++;
    }
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top