添加了一个SegmentedContro控件,想按第3个按钮时segmengtedContro下方出现一个tableView,
firstViewController.m:-(IBAction)myAction:(id)sender
{
NSInteger index = ((UISegmentedControl *)sender).selectedSegmentIndex;
switch (index) {
case 0:[self loadView_0]; break;
case 1:[self loadView_1]; break;
case 2:[self loadView_2]; break;
case 3:[self loadView_3]; break;
}
}
-(void)loadView_2
{
secondViewController *secondVC = [[secondViewController alloc] init];
[self.view addSubview:secondVC.view];
}
secondViewController.h:#import <UIKit/UIKit.h>
@interface secondViewController : UIViewController<UITableViewDataSource>
{
@private
UITableView *_tableViews;
}
@property (nonatomic,retain) NSArray *listArray;
@end
secondViewController.m:-(void)loadView
{
UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 154, 320, 300)];
self.view = baseView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_listArray = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"];
_tableViews = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 300) style:UITableViewStylePlain];
_tableViews.dataSource = self;
[self.view addSubview:_tableViews];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.listArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"mycell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
NSString *text = [_listArray objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = text;
return cell;
}
代码差不多就这。
cmd+R可以正常运行,当按SegmentedContro控件第三个按钮时,tableView也可以正常的显示,但是当点住表往上或者往下拉的时候,程序就崩溃了,窗口里就显示一个(lldb)。代码窗口在:0x10ef09f: movl (%edi), %esi 停住。提示EXC_BAD_ACCESS(code=1,address=0x69202020)。不知道错误在哪。
firstViewController.m:-(IBAction)myAction:(id)sender
{
NSInteger index = ((UISegmentedControl *)sender).selectedSegmentIndex;
switch (index) {
case 0:[self loadView_0]; break;
case 1:[self loadView_1]; break;
case 2:[self loadView_2]; break;
case 3:[self loadView_3]; break;
}
}
-(void)loadView_2
{
secondViewController *secondVC = [[secondViewController alloc] init];
[self.view addSubview:secondVC.view];
}
secondViewController.h:#import <UIKit/UIKit.h>
@interface secondViewController : UIViewController<UITableViewDataSource>
{
@private
UITableView *_tableViews;
}
@property (nonatomic,retain) NSArray *listArray;
@end
secondViewController.m:-(void)loadView
{
UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 154, 320, 300)];
self.view = baseView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_listArray = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"];
_tableViews = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 300) style:UITableViewStylePlain];
_tableViews.dataSource = self;
[self.view addSubview:_tableViews];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.listArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"mycell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
NSString *text = [_listArray objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.text = text;
return cell;
}
代码差不多就这。
cmd+R可以正常运行,当按SegmentedContro控件第三个按钮时,tableView也可以正常的显示,但是当点住表往上或者往下拉的时候,程序就崩溃了,窗口里就显示一个(lldb)。代码窗口在:0x10ef09f: movl (%edi), %esi 停住。提示EXC_BAD_ACCESS(code=1,address=0x69202020)。不知道错误在哪。
这句NSString不能直接引用,用NSString的stringWithString重新构造个试试。
双核,让 A5 芯片双倍强大。iPhone 4S 快速,反应灵敏,当你启动应用软件、浏览网页,以及做各种操作时,就会体验到它所成就的与众不同。而且无论你正在做什么,都可以持续进行。A5 芯片具有极高的效能,赋予 iPhone 4S 超长的电池使用时间。追问那请问与A5X有何区别呢 回答Apple A5X是由美国苹果公司所设计的双核心处理器(图形处理器为四核心),用于第三代iPad,
"The new ipad",中文“全新ipad”。苹果公司声称其速度是NVIDIA Tegra 3的两倍,而图形性能是后者的四倍http://event.t.qq.com/169414http://event.t.qq.com/171377http://event.t.qq.com/171374 也就是说是A5的升级版 追问( ⊙ o ⊙ )啊!那请问A5好不好呢 回答不知你说的好是什么概念,但是用在苹果自己的系统上面非常的流畅。但是由于A5处理器是苹果自己设计的处理器所以只用在自家的产品上面,现在只用在ipad2和iphone4s上,性能上肯定不错,但是和其他的处理器比如ARM之类的没有直接的可比性因为处理器的架构指令都不太一样。别忘了采纳答案 提问者评价toau asnidoho!谢谢[size=12px][size=24px]http://event.t.qq.com/171371http://event.t.qq.com/171365http://event.t.qq.com/169387
http://event.t.qq.com/169375[/size][/size]