如题,我的uitextview加载数据的时候,由于数据过多,超出了屏幕的高度,往下拉的时候,可以滚动,但是无法滚动到最后一条数据。
以下是我的关键代码:
#import "QQQKBViewController.h"
@interface CardSearchViewController : UIViewController
{
QQQKBViewController *qqqkbView;
}
@property (weak, nonatomic) IBOutlet UITableView *cardSearchTableView;
@property (weak, nonatomic) IBOutlet UINavigationItem *cardSearchTopItem;
@property NSArray *dataList;
@end
//
// CardSearchViewController.m
// USMC
//
// Created by Jonathan on 12-12-19.
// Copyright (c) 2012年 Jonathan. All rights reserved.
//
#import "CardSearchViewController.h"
@interface CardSearchViewController ()
@end
@implementation CardSearchViewController
@synthesize cardSearchTableView, cardSearchTopItem, dataList;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
-(void)back
{
[self.view removeFromSuperview];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
//添加返回按钮
UIBarButtonItem *leftBtn = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(back)];
[self.cardSearchTopItem setLeftBarButtonItem:leftBtn];
self.dataList = [[NSArray alloc]initWithObjects:@"考勤记录查询",@"考勤日报表",@"考勤月报表",@"全勤情况表",@"会议记录查询",@"会议室使用情况查询",@"门禁记录查询",@"设备消费查询",@"访客记录统计",@"个人一卡通情况查询",@"神农大酒店消费记录",@"金叶大酒店消费记录",nil];
self.cardSearchTableView.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"tobacoo.png"]];
[self.cardSearchTableView setContentSize:self.view.frame.size];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
#pragma mark -
#pragma mark Table View Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return [self.dataList count];
}
//设置行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *TableSampleIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
TableSampleIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:TableSampleIdentifier];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [self.dataList objectAtIndex:row];
cell.imageView.image = [UIImage imageNamed:@"card_category_1.png"];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//判断用户选中的cell,打开不同的窗体
NSString *rowString = [self.dataList objectAtIndex:[indexPath row]];
if ([rowString isEqualToString:@"考勤日报表"] == YES ) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"tip" message:@"考勤日报表" delegate:self cancelButtonTitle:@"cancle" otherButtonTitles:@"ok", nil];
[alert show];
}else if([rowString isEqualToString:@"考勤日报表"] == YES){
}else if([rowString isEqualToString:@"全勤情况表"] == YES){
qqqkbView = [[QQQKBViewController alloc] initWithNibName:@"QQQKBViewController" bundle:nil];
[self.view addSubview:qqqkbView.view];
}else if([rowString isEqualToString:@"会议记录查询"] == YES){
}else if([rowString isEqualToString:@"会议室使用情况查询"] == YES){
}else if([rowString isEqualToString:@"门禁记录查询"] == YES){
}else if([rowString isEqualToString:@"设备消费查询"] == YES){
}else if([rowString isEqualToString:@"访客记录统计"] == YES){
}else if([rowString isEqualToString:@"个人一卡通情况查询"] == YES){
}else if([rowString isEqualToString:@"神农大酒店消费记录"] == YES){
}else if([rowString isEqualToString:@"金叶大酒店消费记录"] == YES){
}
}
@end