Select TableView Row Programmatically(Swipe Menu)
+(void)settingTableViewRowSelected:(UITableView *)myTableView selectedRow:(NSInteger)row{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
[myTableView selectRowAtIndexPath:indexPath animated:YESscrollPosition:UITableViewScrollPositionNone];
//[myTableView.delegate tableView:APP_DELEGATE.menuVC.tableView didSelectRowAtIndexPath:indexPath];
}
Other TableView Method
#pragma mark - TableView Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return array.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[array objectAtIndex:section] count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return @"title";
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
return 100;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
//put your values, this is part of my code
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.bounds.size.width, 40.0f)];
[view setBackgroundColor:[UIColor colorWithRed:(0.0/255.0) green:(140.0/255.0) blue:(204.0/255.0) alpha:1.0]];
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 3,self.view.bounds.size.width, 20)];
//lbl.frame = view.frame;
lbl.textAlignment = NSTextAlignmentCenter;
[lbl setFont:[UIFont fontWithName:AppFONT size:15.0]];
[lbl setTextColor:[UIColor whiteColor]];
[view addSubview:lbl];
[lbl setText:@"title";
return view;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{
}
No comments:
Post a Comment