Mercurial > dwindows
comparison ios/dw.m @ 2831:adb0e4ce9347
iOS: Fix multi-line container display, had to stop using buttons for images.
Still need to connect the signal handlers to the column buttons.
Switch to using Multi-line container mode in the test program on mobile.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 10 Sep 2022 22:03:47 +0000 |
parents | cc9258ba53d7 |
children | df16bb0a11b2 |
comparison
equal
deleted
inserted
replaced
2830:cc9258ba53d7 | 2831:adb0e4ce9347 |
---|---|
2402 id subviews = [stack arrangedSubviews]; | 2402 id subviews = [stack arrangedSubviews]; |
2403 int index = 0; | 2403 int index = 0; |
2404 | 2404 |
2405 /* Extra mode stack is horizontal, multi stack is vertical */ | 2405 /* Extra mode stack is horizontal, multi stack is vertical */ |
2406 [stack setAxis:(extra ? UILayoutConstraintAxisHorizontal : UILayoutConstraintAxisVertical)]; | 2406 [stack setAxis:(extra ? UILayoutConstraintAxisHorizontal : UILayoutConstraintAxisVertical)]; |
2407 /* For Multi-line, we don't want fill, we want leading */ | |
2408 if(!extra) | |
2409 [stack setAlignment:UIStackViewAlignmentLeading]; | |
2407 | 2410 |
2408 /* Create the stack using columndata, reusing objects when possible */ | 2411 /* Create the stack using columndata, reusing objects when possible */ |
2409 for(id object in columndata) | 2412 for(id object in columndata) |
2410 { | 2413 { |
2411 if([object isKindOfClass:[NSString class]]) | 2414 if([object isKindOfClass:[NSString class]]) |
2416 if(index < [subviews count]) | 2419 if(index < [subviews count]) |
2417 { | 2420 { |
2418 id oldview = [subviews objectAtIndex:index]; | 2421 id oldview = [subviews objectAtIndex:index]; |
2419 | 2422 |
2420 if([oldview isMemberOfClass:(extra ? [UILabel class] : [UIButton class])]) | 2423 if([oldview isMemberOfClass:(extra ? [UILabel class] : [UIButton class])]) |
2421 { | |
2422 label = oldview; | 2424 label = oldview; |
2423 /* If we are reusing a button, make sure the image is not set */ | |
2424 if(!extra) | |
2425 [label setImage:nil forState:UIControlStateNormal]; | |
2426 } | |
2427 else | 2425 else |
2428 [stack removeArrangedSubview:oldview]; | 2426 [stack removeArrangedSubview:oldview]; |
2429 } | 2427 } |
2430 if(!label) | 2428 if(!label) |
2431 { | 2429 { |
2454 /* Check if we already have a view, reuse it if possible.. */ | 2452 /* Check if we already have a view, reuse it if possible.. */ |
2455 if(index < [subviews count]) | 2453 if(index < [subviews count]) |
2456 { | 2454 { |
2457 id oldview = [subviews objectAtIndex:index]; | 2455 id oldview = [subviews objectAtIndex:index]; |
2458 | 2456 |
2459 if([oldview isMemberOfClass:(extra ? [UIImageView class] : [UIButton class])]) | 2457 if([oldview isMemberOfClass:[UIImageView class]]) |
2460 { | |
2461 image = oldview; | 2458 image = oldview; |
2462 /* If we are reusing a button, make sure the text is not set */ | |
2463 if(!extra) | |
2464 [image setTitle:nil forState:UIControlStateNormal]; | |
2465 } | |
2466 else /* Remove the view if it won't work */ | 2459 else /* Remove the view if it won't work */ |
2467 [stack removeArrangedSubview:oldview]; | 2460 [stack removeArrangedSubview:oldview]; |
2468 } | 2461 } |
2469 if(!image) | 2462 if(!image) |
2470 { | 2463 { |
2471 image = extra ? [[UIImageView alloc] init] : [UIButton buttonWithType:UIButtonTypeCustom]; | 2464 image = [[UIImageView alloc] init]; |
2472 | 2465 |
2473 [image setTranslatesAutoresizingMaskIntoConstraints:NO]; | 2466 [image setTranslatesAutoresizingMaskIntoConstraints:NO]; |
2474 | 2467 |
2475 if(index < [subviews count]) | 2468 if(index < [subviews count]) |
2476 [stack insertArrangedSubview:image atIndex:index]; | 2469 [stack insertArrangedSubview:image atIndex:index]; |
2477 else | 2470 else |
2478 [stack addArrangedSubview:image]; | 2471 [stack addArrangedSubview:image]; |
2479 } | 2472 } |
2480 /* Set the image view or button image */ | 2473 /* Set the image view or button image */ |
2481 if(extra) | 2474 [image setImage:object]; |
2482 [image setImage:object]; | |
2483 else | |
2484 [image setImage:image forState:UIControlStateNormal]; | |
2485 | 2475 |
2486 index++; | 2476 index++; |
2487 } | 2477 } |
2488 } | 2478 } |
2489 } | 2479 } |
2615 id cell = [data objectAtIndex:index]; | 2605 id cell = [data objectAtIndex:index]; |
2616 CGFloat height = 0.0; | 2606 CGFloat height = 0.0; |
2617 | 2607 |
2618 /* The data is already a DWTableViewCell so just return that */ | 2608 /* The data is already a DWTableViewCell so just return that */ |
2619 if([cell isMemberOfClass:[DWTableViewCell class]]) | 2609 if([cell isMemberOfClass:[DWTableViewCell class]]) |
2620 { | |
2621 height = [[cell contentView] systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; | 2610 height = [[cell contentView] systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; |
2622 NSLog(@"Calculated height %f\n", (float)height); | |
2623 } | |
2624 return height > 0.0 ? height : UITableViewAutomaticDimension; | 2611 return height > 0.0 ? height : UITableViewAutomaticDimension; |
2625 } | 2612 } |
2626 -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath | 2613 -(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath |
2627 { | 2614 { |
2628 return _dw_container_mode > DW_CONTAINER_MODE_DEFAULT ? 85.0 : 44.0; | 2615 return _dw_container_mode > DW_CONTAINER_MODE_DEFAULT ? 85.0 : 44.0; |