Closed avinashvaghasiya closed 8 years ago
hello, i am using YUTableView in my app in side menu i am copy table and all file but table view is not call
@implementation SideMenuViewController @synthesize tbl_view;
(void) setTable { tbl_view.showAllItems = [_tableProperties [@"showAll"] boolValue]; tbl_view.scrollToTopWhenAnimationFinished = [_tableProperties [@"scrollToTop"] boolValue]; tbl_view.insertRowAnimation = [_tableProperties [@"insertAnimation"] integerValue]; tbl_view.deleteRowAnimation = [_tableProperties [@"deleteAnimation"] integerValue]; tbl_view.userInteractionEnabledDuringAnimation = [_tableProperties [@"userInt"] boolValue]; tbl_view.parentView = self;
[tbl_view setCellsFromArray: [self createCellItems] cellIdentifier: @"BasicTableViewCell"]; [tbl_view setRootItem: [[YUTableViewItem alloc] initWithData: @"Back"]]; tbl_view.competitionBlock = ^(void) { NSLog( @"Animation completed!"); }; }
(NSArray ) createCellItems { NSMutableArray * array = [NSMutableArray array]; NSArray * types = @[@"Dog", @"Cat", @"Unicorn", @"Phoenix"]; for (int i = 0; i < 5; i++) { YUTableViewItem * mainItem = [[YUTableViewItem alloc] initWithData: [NSString stringWithFormat:@"Item %i", i]]; NSMutableArray \ subItemList = [NSMutableArray arrayWithCapacity: 4];
for (NSString * t in types) { ComplexItem * complexItem = [[ComplexItem alloc] initWithType: t]; YUTableViewItem * subItem = [[YUTableViewItem alloc] initWithData: complexItem]; subItem.cellIdentifier = @"ComplexMainTableViewCell"; NSMutableArray * loremItemList = [NSMutableArray arrayWithCapacity: complexItem.randomSubitems.count]; for (NSString * s in complexItem.randomSubitems) { YUTableViewItem * lorem = [[YUTableViewItem alloc] initWithData: s]; lorem.cellIdentifier = @"ComplexSubTableViewCell"; [loremItemList addObject: lorem]; } subItem.subItems = loremItemList; [subItemList addObject: subItem]; } mainItem.subItems = subItemList; [array addObject: mainItem];
} return array; }
(void)didSelectedRow:(YUTableViewItem )item { NSString \ msg;
if ([item.cellIdentifier isEqualToString:@"ComplexMainTableViewCell"]) msg = ((ComplexItem *)item.itemData).name; else msg = item.itemData;
if (item.subItems.count == 0) { UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Info" message: msg delegate: nil cancelButtonTitle: @"OK" otherButtonTitles: nil]; [alert show]; } else { NSLog(@"%@ selected", msg); } }
but heightForItem,didSelectedRow not call
Since you're not initing table view in this code, I assume it's in storyboard. Are you sure if tbl_view is correctly connected and its type is set as YUTableView?
tbl_view
YUTableView
hello, i am using YUTableView in my app in side menu i am copy table and all file but table view is not call
import "SideMenuViewController.h"
import "MFSideMenu.h"
import "YUTableView.h"
import "ComplexItem.h"
include
@implementation SideMenuViewController @synthesize tbl_view;
pragma mark - Table Init
(void) setTable { tbl_view.showAllItems = [_tableProperties [@"showAll"] boolValue]; tbl_view.scrollToTopWhenAnimationFinished = [_tableProperties [@"scrollToTop"] boolValue]; tbl_view.insertRowAnimation = [_tableProperties [@"insertAnimation"] integerValue]; tbl_view.deleteRowAnimation = [_tableProperties [@"deleteAnimation"] integerValue]; tbl_view.userInteractionEnabledDuringAnimation = [_tableProperties [@"userInt"] boolValue]; tbl_view.parentView = self;
[tbl_view setCellsFromArray: [self createCellItems] cellIdentifier: @"BasicTableViewCell"]; [tbl_view setRootItem: [[YUTableViewItem alloc] initWithData: @"Back"]]; tbl_view.competitionBlock = ^(void) { NSLog( @"Animation completed!"); }; }
(NSArray ) createCellItems { NSMutableArray * array = [NSMutableArray array]; NSArray * types = @[@"Dog", @"Cat", @"Unicorn", @"Phoenix"]; for (int i = 0; i < 5; i++) { YUTableViewItem * mainItem = [[YUTableViewItem alloc] initWithData: [NSString stringWithFormat:@"Item %i", i]]; NSMutableArray \ subItemList = [NSMutableArray arrayWithCapacity: 4];
} return array; }
pragma mark - YUTableViewDelegate
(void)didSelectedRow:(YUTableViewItem )item { NSString \ msg;
if ([item.cellIdentifier isEqualToString:@"ComplexMainTableViewCell"]) msg = ((ComplexItem *)item.itemData).name; else msg = item.itemData;
if (item.subItems.count == 0) { UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Info" message: msg delegate: nil cancelButtonTitle: @"OK" otherButtonTitles: nil]; [alert show]; } else { NSLog(@"%@ selected", msg); } }
but heightForItem,didSelectedRow not call