Ios 调用子视图
这是头文件Ios 调用子视图,ios,Ios,这是头文件 #import "sideTableViewController.h" @interface sideTableViewController () { NSArray *colours; } @end @implementation sideTableViewController @synthesize colorNames; @synthesize sideTableView; - (id)initWithNibName:(NSString *)nibNameOrNi
#import "sideTableViewController.h"
@interface sideTableViewController ()
{
NSArray *colours;
}
@end
@implementation sideTableViewController
@synthesize colorNames;
@synthesize sideTableView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.sideTableView.delegate= self;
self.sideTableView.dataSource=self;
colorNames = [NSArray arrayWithObjects:@"Archie",@"Sethi",@"Rajan" ,@"Deepak" ,nil];
}
- (NSInteger)sideTableView:(UITableView *)sideTableView numberOfRowsInSection:(NSInteger)section
{
return [colorNames count];
}
- (UITableViewCell *)sideTableView:(UITableView *)sideTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
cell = [sideTableView dequeueReusableCellWithIdentifier:@"MyCell"];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"];
}
cell.textLabel.text =[colorNames objectAtIndex:indexPath.row];
// NSLog(@"the indexpath is %@",indexPath);
return cell;
}
- (void)sideTableView:(UITableView *)sideTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [sideTableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
[sideTableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
#导入
@界面侧表ViewController:UIViewController
{
NSArray*颜色名称;
}
@属性(强,非原子)IBUITableView*sideTableView;
-(IBAction)显示消息;
@属性(非原子,保留)NSArray*颜色名称;
@结束
我正在尝试将图像作为现有tableview的背景。
关于:[sideTableViewController tableView:numberOfRowsInSection:]我收到一个异常:未识别的选择器发送到实例0x7593640
请帮助我,我是IOS编程新手 此代码可以帮助您将下面的代码添加到上面的代码中吗
#import <UIKit/UIKit.h>
@interface sideTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
NSArray *colorNames;
}
@property (strong, nonatomic) IBOutlet UITableView *sideTableView;
-(IBAction)showMessage;
@property (nonatomic, retain) NSArray *colorNames;
@end
添加此代码
- (NSInteger)sideTableView:(UITableView *)sideTableView numberOfRowsInSection:(NSInteger)section
是否在Xib/Storyboard中为Tableview设置了数据源和委托?用标准UITableView委托和数据源方法替换委托和数据源方法。阅读此我已经这样做了,你可以提供我的代码,你可以在上面的链接看到。你可以在上面的链接上获得足够多的资料。就走一次谢谢你的支持。。你能把密码寄给我吗。。。我的邮件id是-architgrover@hotmail.com
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}