UITableViewCell clear color delay - ios

I have two UITableViews, the first (FirstViewController.h) is the menus and the second (SecondViewController.h), the menuItems. My problem is when I make the cell from the second tableView clearColor, when I make a selection from the FirstViewController, the item on SecondViewController appear as delayed.
#interface FirstViewController ()
#end
#implementation FirstViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_items = [[NSMutableArray alloc] init];
[_items addObject:#"Menu1"];
[_items addObject:#"Menu2"];
[_items addObject:#"Menu3"];
[_items addObject:#"Menu4"];
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:#"light.png"]];
self.tableView.backgroundColor = [UIColor clearColor];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_items count];
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor clearColor];
cell.layer.backgroundColor = [UIColor clearColor].CGColor;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSString *item = [_items objectAtIndex:indexPath.row];
[[cell textLabel] setText:item];
cell.textLabel.textColor = [UIColor whiteColor];
return cell;
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"MenuItems"]) {
SecondViewController *secondViewController = [segue destinationViewController];
_items = [[NSMutableArray alloc] initWithObjects:#"MenuItem 1", #"MenuItem 2", #"MenuItem 3", #"MenuItem 4", nil];
[secondViewController setItems:_items];
}
}
#end
//--------------------------------------------------------------------------
#implementation SecondViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.parentViewController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"light.png"]];
self.tableView.backgroundColor = [UIColor clearColor];
UIBarButtonItem *btnBack = [[UIBarButtonItem alloc] initWithTitle:#"Menu" style:UIBarButtonItemStyleBordered target:self action:#selector(onClick_btnBack:)];
self.navigationItem.leftBarButtonItem = btnBack;
}
-(IBAction)onClick_btnBack:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_items count];
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor clearColor];
cell.layer.backgroundColor = [UIColor clearColor].CGColor;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSString *item = [_items objectAtIndex:indexPath.row];
[[cell textLabel] setText:item];
cell.textLabel.textColor = [UIColor whiteColor];
return cell;
}
#end

Related

showing NSMutabelArray in tableViewController in objective c

I am passing NSMutableArray to another a tableview and I want to show it in the table view. My NSMutableArray is as follows
2017-02-07 18:32:24.086 krib[13753:2978659] (
"Balcony.png",
"Utilities Included.png",
"Air-conditioning.png",
"Stove.png",
"WiFi Included.png",
"Queen Bed.png",
"Dining Table.png",
"Washing Machine.png",
"Dryer.png",
"Sofa.png",
"TV.png",
"Curtains.png",
"Refrigerator.png",
"Water Heater.png",
"Microwave Oven.png"
)
I send data as,
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:#"segue"]) {
MZFormSheetPresentationViewControllerSegue *presentationSegue = (id)segue;
presentationSegue.formSheetPresentationController.presentationController.shouldApplyBackgroundBlurEffect = YES;
UINavigationController *navigationController = (id)presentationSegue.formSheetPresentationController.contentViewController;
AmennitiesTableTableViewController *presentedViewController = [navigationController.viewControllers firstObject];
// presentedViewController.textFieldBecomeFirstResponder = YES;
presentedViewController.passingString = facilities;
}
and receive data in table view controller,
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Close" style:UIBarButtonItemStylePlain target:self action:#selector(close)];
NSLog(#"%#",self.passingString);
[self.tableView reloadData];
}
I tried showing the mutable array as follows,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = #"facilitiesCell";
AmenitiesTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell.facilitylbl.text = [self.passingString objectAtIndex:indexPath.row];
// Configure the cell...
return cell;
}
But I am not understanding what exactly i am missing to Populate data on the tableview.
I think you are missing to set tableview delegate & datasource.
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Close" style:UIBarButtonItemStylePlain target:self action:#selector(close)];
[self.myTable setDelegate:self];
[self.myTable setDataSource:self];
NSLog(#"%#",self.passingString);
[self.tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return self.passingString.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = #"facilitiesCell";
AmenitiesTableCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(self.passingString.count > 0){
cell.facilitylbl.text = [self.passingString objectAtIndex:indexPath.row];
}
// Configure the cell...
return cell;
}

tableview doesn't see the title for header in section method

I was trying to create a custom viewForHeaderInSection for my tableview.Tableview itself
works fine, but for some reason, compiler skips,
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{}
Delegate method, and I tried what is written on the reference , and this .But for some reason it just doesn't read these methods. Obviously, I am doing something wrong. If someone can point my mistake out, I would appreciate. Thank you in advance.
#import "TableViewController.h"
#interface TableViewController ()
#end
#implementation TableViewController
#synthesize settingTableView,audioPlayer,labelSwitch,descriptiveSwitch,autoPlaySwitch;;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.settingTableView.tableFooterView = [[UIView alloc]init];
self.settingTableView.scrollEnabled = NO;
settings = #{#"Animation Sets" : #[#"Set1",#"Set2",#"Set3"],#"Settings" : #[#"Label",#"Sound",#"Autoplay"]};
values = [[settings allKeys]sortedArrayUsingSelector:#selector(localizedStandardCompare:)];
[settingTableView setRowHeight:44];
[settingTableView reloadData];
}
-(void)close:(id)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
[self.delegate closeView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return [values count];
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return [values objectAtIndex:section];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
NSString *sectionTitle = [values objectAtIndex:section];
NSArray *sectionValue = [settings objectForKey:sectionTitle];
return [sectionValue count];
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
CGRect frame = tableView.frame;
NSString *value = [values objectAtIndex:section];
UILabel *title = [[UILabel alloc]init];
UIView *headerView = [[UIView alloc]init];
//if (section == 0 && section == 1) {
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7.0")) {
title.frame = CGRectMake(10,10,150,30);
}
else
{
title.frame = CGRectMake(10,5,100,30);
}
title.backgroundColor = [UIColor clearColor];
title.text = value;
headerView.frame = CGRectMake(0,0,frame.size.width,frame.size.height);
headerView.backgroundColor = [UIColor clearColor];
[headerView addSubview:title];
[headerView setBackgroundColor:[UIColor blueColor]];
//}
return headerView;
[settingTableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = nil;
static NSString *MyCellIdentifier = #"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:nil];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyCellIdentifier];
cell.textLabel.numberOfLines = 2;
cell.textLabel.font = [UIFont fontWithName:#"Helvetica" size:17.0];
NSString *sectionTitle = [values objectAtIndex:indexPath.section];
NSArray *sectionValue= [settings objectForKey:sectionTitle];
NSString *settingValues = [sectionValue objectAtIndex:indexPath.row];
cell.textLabel.text = settingValues;
return cell;
}
}
You need to make sure that the class that implements that delegate method is the delegate and dataSource of your table view.

Load Array in UITableView Cell

I want to make paging swipe left and right using UIScrollView after view detailController.
First, main.m:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
OZDetailViewController *detailViewController = [[OZDetailViewController alloc] initWithNibName:#"OZDetailViewController" bundle:nil];
detailViewController.arrDetailNews = [_arrNews objectAtIndex:indexPath.row];
[self.navigationController pushViewController:detailViewController animated:YES];
OZDetailViewController *arrNewsAll = [[OZDetailViewController alloc] initWithNibName:#"OZDetailViewController" bundle:nil];
arrNewsAll.allNewsArray = _arrNews;
[self.navigationController pushViewController:arrNewsAll animated:YES];
}
When I selected content in tableviewcell, arrDetailNews can loaded in method viewDidLoad() and cellForRowAtIndexPath(). But arrNewsAll cannot loaded in method cellForRowAtIndexPath().
This is my detailViewController.h:
#property (nonatomic, copy) NSArray *allNewsArray;
And detailViewCOntroller.m:
#synthesize allNewsArray;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.separatorColor = [UIColor clearColor];
NSLog(#"dataArray: %#", allNewsArray);
}
- (int)numberINSectionsInTableView: (UITableView *)tableView
{
return 1;
}
- (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(#"dataArrayCell: %#", allNewsArray);
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:#"New Cell"];
}
if(indexPath.row != self.arrDetailNews.count-1){
UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(0, 44, 320, 2)];
line.backgroundColor = [UIColor whiteColor];
[cell addSubview:line];
}
tableView.allowsSelection = NO;
cell.textLabel.text = [NSString stringWithFormat:#"%u", indexPath.row];
if (indexPath.row==0) {
cell.textLabel.text = #"1st";
}
if (indexPath.row==1) {
cell.textLabel.text = #"2nd";
}
if (indexPath.row==2) {
cell.textLabel.text = #"3rd";
}
return cell;
}
If allNewsArray can loaded in cellForRowAtIndexPath() I can continue next step for paging with UIScrollView. Note, numberOfRowsInSection I set to 4 because I need 4 rows (custom view).
Assuming you setup your delegate & dataSource outlets correctly from xib/storyboard, you still need to specify the number of rows per section (or number of sections).
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return allNewsArray.count;
}
Alternatively, the method for number of sections is:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;

Add subview to UITableViewCell as replacement for cell selection

In my tableview each cell gets a subview by didselectRowAtIndexPath to highlight the current selected row. Everything works fine but in the moment when the tableview was scrolled the subview won't hide from a cell which was selected before.
In short: How do you would make a replacement for "Managing Cell Selection and Highlighting"?
Thanks in advance!
Here is my code:
#import "ViewController.h"
#interface ViewController () <UITableViewDataSource, UITableViewDelegate>
#property (nonatomic,strong) NSArray *tableData;
#end
#implementation ViewController
#synthesize checked_icon;
- (void)viewDidLoad {
[super viewDidLoad];
self.tableData = #[#"A",#"B",#"C",#"D",#"E",#"F",#"G",#"H",#"I",#"J",#"K",#"L",#"M",#"N",#"O",#"P",#"Q",#"R",#"S",#"T"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
checked_icon = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 44)];
checked_icon.backgroundColor =[UIColor redColor];
}
cell.textLabel.text = self.tableData[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSIndexPath *currentSelectedIndexPath = [tableView indexPathForSelectedRow];
if (currentSelectedIndexPath != nil)
{
[[tableView cellForRowAtIndexPath:currentSelectedIndexPath] setBackgroundColor: [UIColor whiteColor]];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:currentSelectedIndexPath];
if (cell.isSelected == YES) {
checked_icon.backgroundColor = [UIColor redColor];
}
else {
checked_icon.backgroundColor = [UIColor clearColor];
}
}
return indexPath;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[[tableView cellForRowAtIndexPath:indexPath] setBackgroundColor:[UIColor lightGrayColor]];
UITableViewCell *selectedcell = [tableView cellForRowAtIndexPath:indexPath];
[selectedcell.contentView addSubview:checked_icon];
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (cell.isSelected == YES) {
[cell setBackgroundColor:[UIColor lightGrayColor]];
}
else {
[cell setBackgroundColor:[UIColor whiteColor]];
}
}
#end
You should use 'selectedBackgroundView' property of UITableViewCell, as selection will be handled for you.
EDIT
The proper way to do this would be to create a subclass of UITableViewCell and have a reference to your checkmark in there.
While the code from my original post will work, it's not the best way to do it and will quickly get complicated if your cell view gets more complex.
ORIGINAL
If you don't want to use 'selectedBackgroundView', then this should probably solve your problem:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UIView *checked_icon = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 44)];
checked_icon.tag = 1234;
[cell.contentView addSubview:checked_icon];
}
UIView *checked_icon = [cell.contentView viewWithTag:1234];
// Note: color should be set each time a cell is presented
if (cell.isSelected) {
checked_icon.backgroundColor = [UIColor redColor];
}
else {
checked_icon.backgroundColor = [UIColor clearColor];
}
cell.textLabel.text = self.tableData[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
Thanks to MrNickBarker!
viewWithTag seems to be the one and only solution...
Here is the code: (not perfect but it works)
#import "ViewController.h"
#interface ViewController () <UITableViewDataSource, UITableViewDelegate>
#property (nonatomic,strong) NSArray *tableData;
#end
#implementation ViewController
#synthesize checked_icon;
- (void)viewDidLoad {
[super viewDidLoad];
self.tableData = #[#"A",#"B",#"C",#"D",#"E",#"F",#"G",#"H",#"I",#"J",#"K",#"L",#"M",#"N",#"O",#"P",#"Q",#"R",#"S",#"T"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat:#"cell-%d",indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
checked_icon = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 44)];
checked_icon.tag = 1234;
[cell.contentView addSubview:checked_icon];
}
cell.textLabel.text = self.tableData[indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSIndexPath *currentSelectedIndexPath = [tableView indexPathForSelectedRow];
if (currentSelectedIndexPath != nil) {
[[tableView cellForRowAtIndexPath:currentSelectedIndexPath] setBackgroundColor: [UIColor whiteColor]];
UITableViewCell *selectedcell = [tableView cellForRowAtIndexPath:currentSelectedIndexPath];
checked_icon = [selectedcell.contentView viewWithTag:1234];
if (selectedcell.isSelected == YES) {
checked_icon.backgroundColor = [UIColor redColor];
}
else {
checked_icon.backgroundColor = [UIColor clearColor];
}
}
checked_icon.backgroundColor = [UIColor clearColor];
return indexPath;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[[tableView cellForRowAtIndexPath:indexPath] setBackgroundColor:[UIColor lightGrayColor]];
UITableViewCell *selectedcell = [tableView cellForRowAtIndexPath:indexPath];
checked_icon = [selectedcell.contentView viewWithTag:1234];
if (selectedcell.isSelected == YES) {
NSLog(#"redColor");
checked_icon.backgroundColor = [UIColor clearColor];
}
else {
NSLog(#"clearColor");
checked_icon.backgroundColor = [UIColor clearColor];
}
checked_icon.backgroundColor = [UIColor redColor];
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
checked_icon = [cell.contentView viewWithTag:1234];
if (cell.isSelected == YES) {
[cell setBackgroundColor:[UIColor lightGrayColor]];
checked_icon.backgroundColor = [UIColor redColor];
}
else {
[cell setBackgroundColor:[UIColor whiteColor]];
checked_icon.backgroundColor = [UIColor clearColor];
}
}
#end

UITableView clicking on an item an opening a new screen/view/activity

I have a table view(HomeViewController) consisting of items as:
locations
Reporting
Setting
I am having these items as separate files(LocationViewController,ReportingView Controller and Setting ViewController).Now if user clicks on location a new screen/activity/view should be open and same for rest items.
Can some one please help.my code is as:
#import "HomePageController.h" #implementation HomePageController
#synthesize menuList, table;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
menuList=[[NSMutableArray alloc] initWithObjects:
[NSArray arrayWithObjects:#"LOCATIONS",nil],
[NSArray arrayWithObjects:#"REPORTING",nil],
[NSArray arrayWithObjects:#"SETTINGS",nil],
[NSArray arrayWithObjects:#"PASSWORD",nil],
[NSArray arrayWithObjects:#"HELP",nil],
[NSArray arrayWithObjects:#"ABOUT",nil],
[NSArray arrayWithObjects:#"SHARE",nil],
nil];
[self.navigationController setNavigationBarHidden:NO];
self.navigationController.navigationBar.tintColor=[UIColor blackColor];
self.navigationController.navigationBar.barStyle=UIBarStyleBlackTranslucent;
self.title=#"CoinRead";
[table reloadData];
[super viewDidLoad];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)theTableView{
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 40;
}
- (NSInteger)tableView:(UITableView *)theTableView numberOfRowsInSection:(NSInteger)section{
return menuList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = #"CellIdentifier";
UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil){
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease];
}
cell.highlighted=NO;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
NSArray *rowArray = [menuList objectAtIndex:indexPath.row];
UILabel *nameLabel = [[[UILabel alloc] initWithFrame:CGRectMake(15, 8, 200, 20)]autorelease];
nameLabel.text = [NSString stringWithFormat:#"%#",[rowArray objectAtIndex:0]];
nameLabel.backgroundColor = [UIColor clearColor];
nameLabel.shadowColor=[UIColor whiteColor];
nameLabel.shadowOffset=CGSizeMake(0.0, 0.5);
nameLabel.textColor = RGB(0,0,0);
[nameLabel setFont:[UIFont boldSystemFontOfSize:16.0f]];
[cell.contentView addSubview:nameLabel];
return cell;
}
Implement below method of UITableViewDelegate to get the selection event
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

Resources