Skip to content

Commit

Permalink
Rough implementation of table view for UIActionSheet
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Sep 20, 2013
1 parent 73796f7 commit 916fb6e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
38 changes: 38 additions & 0 deletions UI7Kit/UI7ActionSheet.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,44 @@ - (void)_setTheme {
[self insertSubview:backgroundView belowSubview:self.titleLabel];
}

UIView *lastView = self.subviews[self.subviews.count - 1];
if (![lastView isKindOfClass:[UIButton class]]) {
if (frame.origin.y >= 0) {
for (UIView *view in self.subviews) {
view.hidden = NO;
}
lastView.hidden = YES;
} else {
CGFloat diff = frame.size.height - self.superview.bounds.size.height;
frame = self.superview.bounds;
CGFloat top = 2000.0f;
for (UIButton *button in self.buttons) {
if (button.hidden) continue;
if (button.frame.origin.y <= lastView.frame.origin.y) continue;
CGFloat bottom = button.frame.origin.y + button.frame.size.height;
if (bottom >= frame.size.height) {
CGRect bframe = button.frame;
bframe.origin.y -= diff;
button.frame = bframe;
}
top = MIN(top, button.frame.origin.y);
}
[lastView.subviews[1] setHidden:YES];

UIButton *aButton = self.buttons[0];
CGRect tframe = lastView.frame;
tframe.origin.y += 1.0f;
tframe.size.height = top - tframe.origin.y - 10.0f;
tframe.origin.x = aButton.frame.origin.x;
tframe.size.width = aButton.frame.size.width;
lastView.frame = tframe;
UITableView *tableView = lastView.subviews[0];
tableView.frame = lastView.bounds;
//tableView.rowHeight = UI7ControlRowHeight; // separator become ugly
tableView.layer.cornerRadius = .0f;
}
}

self.frame = frame;

if (!isPhone) {
Expand Down
4 changes: 2 additions & 2 deletions UI7KitTestApp/UITDetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ - (void)showActionSheet2:(UISwitch *)sender {

- (void)showActionSheet3:(UISwitch *)sender {
NSString *title = @"Title";
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destructive" otherButtonTitles:@"Other", @"Buttons", @"Is", @"Many", @"At", @"This", @"Time", nil];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destructive" otherButtonTitles:@"Other", @"Buttons", @"Are", @"Many", @"At", @"This", @"Time", nil];
actionSheet.actionSheetStyle = (UIActionSheetStyle)self.navigationController.navigationBar.barStyle;
if (self.tabBarController) {
[actionSheet showFromTabBar:self.tabBarController.tabBar];
Expand All @@ -85,7 +85,7 @@ - (void)showActionSheet3:(UISwitch *)sender {

- (void)showActionSheet4:(UISwitch *)sender {
NSString *title = @"Title is long long longer at this time. How long? This long.";
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destructive" otherButtonTitles:@"Other", @"Buttons", @"Is", @"Many", @"At", @"This", @"Time", nil];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:title delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destructive" otherButtonTitles:@"Other", @"Buttons", @"Are", @"Many", @"Many", @"Many", @"And", @"So", @"Many", @"At", @"This", @"Time", nil];
actionSheet.actionSheetStyle = (UIActionSheetStyle)self.navigationController.navigationBar.barStyle;

if (self.tabBarController) {
Expand Down

0 comments on commit 916fb6e

Please sign in to comment.